Forums

Can't install module (Head First Python exercise)

This is all very new to me, so I am at a loss what further I can do...

(I am following the instructions from Head First Python ed2 pages 533 etc)

Trying to install 'vsearch.zip' (zipped via Windows10) following the instructions in the book.:

python3 -m pip install vsearch.zip --user

The result of this is:

Processing ./vsearch.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.6/tokenize.py", line 452, in open
    buffer = _builtin_open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-0v61tdy0-build/setup.py'

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-0v61tdy0-build/

I get a similar result with:

pip3.6 install --user vsearch.zip

(from the PythonAnywhere fourms)

I have also tried:

  • zipping in different formats (7z, gz, 7zip zip)
  • upgrading according to https://stackoverflow.com/questions/35991403/pip-install-unroll-python-setup-py-egg-info-failed-with-error-code-1 instructions
  • running the install on the unzipped (vsearch.py) file

Anything I have overlooked? Would appreciate it if someone could ELI5 what is going on and how I can progress.

That sounds like whatever you've zipped up is not a pip installable packge. Pip installable packages need a setup.py file in their top level. That is what actually does the install. If you don't have a setup.py file in the top level, then pip cannot use it to do the install.

Thanks for the help; it got me a bit further, but I'm still stuck...

I created a setup.py:

from setuptools import setup
# Source: https://marthall.github.io/blog/how-to-package-a-python-app/
setup(
name='My_Head_First_Python__vsearch_module',    
version='0.1',                           
scripts=['vsearch']      
)

I zipped this together with vsearch.py (in the root of the zip file) and uploaded to PythonAnywhere. Then typed

python3 -m pip install vsearch.zip --user

Which resulted in this:

Processing ./vsearch.zip
Installing collected packages: My-Head-First-Python-vsearch-module    
  Running setup.py install for My-Head-First-Python-vsearch-module ... error
    Complete output from command /home/sj0n/.local/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-3y61nxs9-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-2if6_qn4-record/install-record.txt --
single-version-externally-managed --compile --user --prefix=:
    running install
    running build
    running build_scripts
    creating build
    creating build/scripts-3.6
    error: file '/tmp/pip-3y61nxs9-build/vsearch' does not exist

----------------------------------------
Command "/home/sj0n/.local/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-3y61nxs9-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=
f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-2if6_qn4-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-3y61nxs9-build/

So now it seems vsearch.py is not where its expected. I have tried googling for an answer but seem to be missing something essential. What should I be doing differently?

Also: Does anyone have a link to a good 'Installing modules on PythonAnywhere for noobs'?

It's not about installing the module. It's about creating an installable package. Here's the tutorial for python-packaging: http://python-packaging.readthedocs.io/en/latest/

It appears that the vsearch.zip also needs to include a README.txt file to work. Its contents can be empty, but the file needs to be in the zip package.