LP3THW Ex 46 Required Quiz

Been stuck on the quiz portion of this exercise and I’m not really giving up but I could really use a little help / clues please. I’ve looked at youtube for videos as well as searched the interwebs for help with quiz 46. End of the day I have a lot of questions still as well as error messages (that can be something small that I just missed since I’m a very green rookie).

#3 Make a project and start putting code into the module, then get the module working.

– Ok, I made a simple .py file that’s basically just a “hello world” type of .py. In this case, I named this .py file “yoinks.py”

#4 Put a script in the bin directory that you can run. Read about how you can make a Python script that’s runnable for your system

– Is the script the book talking about the “yoinks.py” that I made? Ok, I placed “yoinks.py” in the bin directory. To make it runnable for my system, that’s the chmod +x bin/yoinks.py ? Do I need to put this “shebang” #!/usr/bin/env python on the top of the yoinks.py?

#5 Mention the bin script you created in your setup.py so that it gets installed.
– This is what my setup.py looks like. Does the packages and scripts portion look correct?

try:
  from setuptools import setup
except ImportError:
  from distutils.core import setup

config = {
    'description':  'My Project Yoink',
    'author':   'My Name',
    'url':  'URL to get it at.',
    'download_url': 'Where to download it.',
    'author_email': 'my.name@emailaddress.com',
    'version': '0.1',
    'install_requires': ['nose'],
    'packages': ['yoinks.py'],
    'scripts':  'bin/yoinks.py',
    'name': 'yoinks'
}

setup(**config)

#6 User your setup.py to install your own module and make sure it works, then use pip to uninstall it.

– The error message is included below. I’m sure my inexperience is what preventing me from seeing something super obvious that is right in front of me. The error “error: package directory ‘yoinks/py’ does not exist” how and where do I fix that? I am using “python3 setup.py install” to try and install my module. As for uninstalling with pip, I have not gotten it to install so I have not made it to the uninstalling part.

(lpthw) homie@test:~/Documents/lpthw/projects/yoinks$ python3 setup.py install
running install
/home/homie/.venvs/lpthw/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/home/homie/.venvs/lpthw/lib/python3.9/site-packages/setuptools/command/easy_install.py:160: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/home/homie/.venvs/lpthw/lib/python3.9/site-packages/pkg_resources/__init__.py:122: PkgResourcesDeprecationWarning: 0.1.39ubuntu1 is an invalid version and will not be supported in a future release
  warnings.warn(
/home/homie/.venvs/lpthw/lib/python3.9/site-packages/pkg_resources/__init__.py:122: PkgResourcesDeprecationWarning: 1.14.0-unknown is an invalid version and will not be supported in a future release
  warnings.warn(
running bdist_egg
running egg_info
creating yoinks.egg-info
writing yoinks.egg-info/PKG-INFO
writing dependency_links to yoinks.egg-info/dependency_links.txt
writing requirements to yoinks.egg-info/requires.txt
writing top-level names to yoinks.egg-info/top_level.txt
writing manifest file 'yoinks.egg-info/SOURCES.txt'
error: package directory 'yoinks/py' does not exist

Apologies in advance for my greeness/rookieness. I wanted to get through the exercises and quizes as much as possible on my own but I’m stuck in this portion and want to move on. The answer is probably so simple that my jaw will drop. Any help or clues to point me where to find answers are deeply appreciated.

Messing around I changed my setup.py a little.

I changed

‘packages’: [‘yoinks.py’] to ‘packages’: [‘yoinks’]

This seems to have done something as python3 setup.py install now does more things but unfortunately now I have a new error message.

Here is the new error message:

(lpthw) homie@test:~/Documents/lpthw/projects/yoinks$ python3 setup.py install
running install
/home/homie/.venvs/lpthw/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/home/homie/.venvs/lpthw/lib/python3.9/site-packages/setuptools/command/easy_install.py:160: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/home/homie/.venvs/lpthw/lib/python3.9/site-packages/pkg_resources/__init__.py:122: PkgResourcesDeprecationWarning: 0.1.39ubuntu1 is an invalid version and will not be supported in a future release
  warnings.warn(
/home/homie/.venvs/lpthw/lib/python3.9/site-packages/pkg_resources/__init__.py:122: PkgResourcesDeprecationWarning: 1.14.0-unknown is an invalid version and will not be supported in a future release
  warnings.warn(
running bdist_egg
running egg_info
writing yoinks.egg-info/PKG-INFO
writing dependency_links to yoinks.egg-info/dependency_links.txt
writing requirements to yoinks.egg-info/requires.txt
writing top-level names to yoinks.egg-info/top_level.txt
reading manifest file 'yoinks.egg-info/SOURCES.txt'
writing manifest file 'yoinks.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/yoinks
copying yoinks/__init__.py -> build/lib/yoinks
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/yoinks
copying build/lib/yoinks/__init__.py -> build/bdist.linux-x86_64/egg/yoinks
byte-compiling build/bdist.linux-x86_64/egg/yoinks/__init__.py to __init__.cpython-39.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
installing scripts to build/bdist.linux-x86_64/egg/EGG-INFO/scripts
running install_scripts
running build_scripts
creating build/scripts-3.9
error: file '/home/homie/Documents/lpthw/projects/yoinks/b' does not exist

Another change:

I left scripts blank this time.

‘scripts’: [ ],

This finally “installed” my simple program. I can see it on the list of installed things when I do pip list. So now, I thought I would be able to see my program if I just type in the name yoinks since it’s suppose to be installed. That is not the case as Linux gives me a command not found error.

Is the program suppose to be able to run anywhere regardless of directory since I “installed” it? If that is the case, I am missing something still as I am getting a command not found error. The program I made basically just says “Hello world”.

Any insight or clues to what I am doing wrong would be deeply appreciated. Thank you.

I think I finally figured this out. I just have to make sure I remember what I did correctly and to be able to replicate it again to make sure I did the right thing.

I think that’s right, but I’d have to see the full project to make sure. If you still need help, find a way to get it into github and give me a link to your repo to check out.

I fixed your posts, but for better formatting in the future do this:

```
# code goes here
```

Or this:

[code]
# code goes here
[/code]

That formats it as a scrollable code block.

Thanks for the reply and for fixing my posts Zed! I finally got through the exercise and was able to “install” it. I was super excited and happy when I finally did it! Then of course something came along to ruin my victory. When I was not able to get the program to run, I was still able to pip uninstall yoinks. When I finally got it to work, this is the latest error message I’m getting. I’ve continued on to the next chapters but I would like to know what is going on here and how to fix this error. The internet has yielded some clues but this is just way above my head that I do not even know where and how to proceed. I basically cannot uninstall the program I made in that virtual environment. Luckily it’s in a virtual environment.

(lpthw) homie@test:~$ pip uninstall yoinks
Found existing installation: yoinks 0.1
ERROR: Exception:
Traceback (most recent call last):                                                                        
 File "/home/homie/.venvs/lpthw/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 167,
in exc_logging_wrapper                                                                                   
   status = run_func(*args)                                                                              
 File "/home/homie/.venvs/lpthw/lib/python3.9/site-packages/pip/_internal/commands/uninstall.py", line 97
, in run                                                                                                  
   uninstall_pathset = req.uninstall(                                                                    
 File "/home/homie/.venvs/lpthw/lib/python3.9/site-packages/pip/_internal/req/req_install.py", line 637,
in uninstall                                                                                              
   uninstalled_pathset = UninstallPathSet.from_dist(dist)                                                
 File "/home/homie/.venvs/lpthw/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py", line 554
, in from_dist                                                                                            
   for script in dist.iterdir("scripts"):                                                                
 File "/home/homie/.venvs/lpthw/lib/python3.9/site-packages/pip/_internal/metadata/pkg_resources.py", lin
e 156, in iterdir                                                                                         
   if not self._dist.isdir(name):                                                                        
 File "/home/homie/.venvs/lpthw/lib/python3.9/site-packages/pip/_vendor/pkg_resources/__init__.py", line
2816, in __getattr__                                                                                      
   return getattr(self._provider, attr)                                                                  
AttributeError: 'EggMetadata' object has no attribute 'isdir'     

So, I think we’re at the point where I’m going to advise you to start trying to solve your own problems for at least a few days before asking for help. When you code on your own stuff you can’t constantly run off to ask for help. At a job you’ll also be expected to solve things on your own, so if you’re constantly asking for help it looks bad. Shouldn’t be that way, but part of the reason I and many other enjoy coding is the problem solving. With that in mind, take your time to solve this on your own, and really confirm you solved it. Take a few days and spend time figuring this out, and next time you get an error, change your default reaction from “I need to ask what this is” to “I need to figure out what this is.” It will help you tremendously.

Sounds good! I’ll try to figure out what I’m doing wrong and post the solution when I find it!

A free service run by Zed A. Shaw for learncodethehardway.org.