10
votes

I am trying to install a package called "simpleguitk" via pip. (On Ubuntu 16.04 with Python 3.5)
After running

sudo -H pip3 install simpleguitk

it says installation is completed successfully. (Except for the pygame dependecy which is actually optional)

Collecting simpleguitk
Using cached SimpleGUITk-1.1.3.tar.gz
Collecting Pillow>=2.0.0 (from simpleguitk)
Using cached Pillow-3.4.2-cp35-cp35m-manylinux1_x86_64.whl
Collecting pygame>=1.9.0 (from simpleguitk)
Could not find a version that satisfies the requirement pygame>=1.9.0 (from simpleguitk) (from versions: 1.9.2.dev1, 1.9.2b7, 1.9.2b8)
No matching distribution found for pygame>=1.9.0 (from simpleguitk)

I cannot find the package at /usr/local/lib/python3.5/dist-packages or /usr/lib/python3.5 or /usr/lib/python3

When I try to import the module it says:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'simpleguitk'

I tried to reinstall it, but running:

sudo -H pip3 uninstall simpleguitk

returns: "Cannot uninstall requirement simpleguitk, not installed "

I have tried this on both pip 8.1.2 and pip 9.0.1 with the same results. I have even reinstalled Ubuntu, but still the same.

I think Python Path is wrong as it does not have python 3.5 but I do not know how to fix it

['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/gtk-2.0']
5
What does ~/.pip.log says ?Flint

5 Answers

16
votes

Make sure you're installing it for the version of python you're using, with

/path/to/your/python -m pip install <package>
6
votes

pip needs python, and sometimes the python you are trying to execute your *.py may not be same as the python binary used by pip.

Can you retry installing following these steps:

which python

Let's say it prints:

/usr/bin/python

Means you can use:

/usr/bin/python -m pip install <package>

Or you can try to choose from the different versions you have of python.

Now try executing you *.py using

/usr/bin/python *.py

0
votes

The issue could be that the version of python you used to install the module does not match the version python you are trying to import from.

  1. Find out whether the module in the python version you wanted you can try using the command: pip3 freeze to get the list of packages installed for version of python(In your case, it is python3.5).

  2. Before that, check different versions of python installed in your machine. You can use the command locate /python | grep /bin if you have python2.7 and python3.5, then you should use the corresponding pip/pip3 to install the modules.

  3. Open the corresponding python shell (python3) and try to import again

0
votes

I had a similar problem with PyCharm, where the dependencies I installed using pip would work for the editor windows (i.e., there were no error reports about imports), but the project would complain about the dependencies when I tried to run it. Turns out, I set up a virtual environment for that project after I created the tasks that ran my project and tests. I had to go to the window where you set up the tasks and make sure that all of them used the correct venv. Hope this is useful.

0
votes

The module may be installed but the program doesn't run. This happens because of 2 different versions of python co-existing. So run your Py Script with the location of the python version you have installed the module for, say usr/bin/python python.py or /usr/bin/python3 python.py.

Hope this helps in your progress!