Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot import a package installed with pip

Tags:

python

pip

I'm trying to add a package for my python(2.7.6) on linux , I used the command:

 pip install crc16

and It sends back :

Requirement already satisfied (use --upgrade to upgrade): crc16 in /usr/local/lib/python3.5/site-packages

As should be. But when i try to run a python script it says

 Traceback (most recent call last):
  File "mos.py", line 1, in <module>
    import crc16
ImportError: No module named crc16

My guess is that pip and the python aren't on the same version.

EDIT** answer: i used easy_install-2.7 crc16 and then python2.7 mos.py

like image 784
Nitzan Farhi Avatar asked May 19 '26 00:05

Nitzan Farhi


2 Answers

You could have done

python -m pip install <module>
like image 196
Seekheart Avatar answered May 20 '26 12:05

Seekheart


Your pip is catching the 3.5 version. You must specifically install pip for 2.7 version for your code to work. This is how it's done:

$ sudo apt-get install python2-pip
$ sudo pip2 install crc16
like image 33
Nickil Maveli Avatar answered May 20 '26 13:05

Nickil Maveli