Search code examples
pythonpython-3.xmodulepypi

Unable to import pypi module


I am unable to import the pypi module (https://pypi.org/project/pypi/) into one of my python scripts.

I added the below line to my script to see which paths it's trying to get modules from:

print(sys.path)

Which shows the following:

`'/usr/local/lib/python3.5/dist-packages/', '/usr/lib/python3.5/dist-packages']

I have used pip to force the installation into those specific folders:

sudo pip3 install --upgrade --target=/usr/local/lib/python3.5/dist-packages/ pypi
sudo pip3 install --upgrade --target=/usr/lib/python3.5/dist-packages pypi

In both cases the installation is successful:

Collecting pypi
Installing collected packages: pypi
Successfully installed pypi-2.1

If I go check those folders, the package is there:

ls -lh /usr/lib/python3.5/dist-packages | grep pypi
drwxr-xr-x 2 root root 4.0K Apr 25 11:03 pypi-2.1.dist-info
drwxr-xr-x 2 root root 4.0K Apr 25 10:49 pypi-2.1-py3.5.egg-info

If I manually install the package I get something similar:

python3.5 ./setup.py install
running install
running build
running install_egg_info
Writing /usr/local/lib/python3.5/dist-packages/pypi-2.1.egg-info

Here is my script:

import sys
print(sys.path)
import pypi

And the error I get:

$ python3.5 myscrypt.py
[..., '/usr/local/lib/python3.5/dist-packages','/usr/lib/python3.5/dist-packages']
import pypi
ImportError: No module named 'pypi'

What am I missing to import pypi?


Solution

  • There are no importable modules or packages in the pypi package. The package was created to reserve the name so that evil hackers don't publish packages with this name.

    What are really trying to install?