helloB
helloB

Reputation: 3582

installing packages for python 3

I tend to run my code in Jupyter notebooks, and these run in python 3. I also have python 2 on my computer. I installed pip3 so I'd be able to install packages specifically for python 3 but this doesn't seem to be working out for me:

mba$ pip3 install multidict
Collecting multidict
  Using cached multidict-2.1.2.tar.gz
Building wheels for collected packages: multidict
  Running setup.py bdist_wheel for multidict ... done
  Stored in directory: /Users/mba/Library/Caches/pip/wheels/6e/f3/6a/c1ff64511c3dc2964ade4f9e59f4d7dfc050bd77e0fcc78ca5
Successfully built multidict
Installing collected packages: multidict
Successfully installed multidict-2.1.2
mba:~ $ python3
Python 3.5.2 |Anaconda custom (x86_64)| (default, Jul  2 2016, 17:52:12) 
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import multidict
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'multidict'
>>> import sys.
  File "<stdin>", line 1
    import sys.
              ^
SyntaxError: invalid syntax
>>> import sys
>>> sys.version
'3.5.2 |Anaconda custom (x86_64)| (default, Jul  2 2016, 17:52:12) \n[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)]'
>>> 

Notice that the multidict install with pip3 succeeded, but when I ran python3 and tried to import multidict, this failed. How can I install the proper Python 3 version of the package I want?

For reference, I'm on Mac OS X El Capitan. I've read the existing SO posts and tried following the advice in these:

These have not done the trick. Thanks for any suggestions.

Upvotes: 3

Views: 2030

Answers (1)

furas
furas

Reputation: 142983

I put comment as answer (after 4 years) because @user20272 suggested that it is useful.


Maybe you have few Python installed and pip3 uses different version than you expect.

First you can check versions (upper V)

pip3 -V 

python3 -V 

You may also check if you don't have also similar commands

pip3.5 -V
pip3.6 -V
pip3.7 -V

python3.5 -V 
python3.6 -V 
python3.7 -V 

Sometimes the simplest method is to use python to install it

python3 -m pip install multidict

Later you can try to clean this mess and put correct pip3.x in place of pip3.

On Linux (and probably on MacOS too) you can go to folder with pip3 and pip3.x, remove pip3 and create symbolic link using

ln -s pip3.5 pip3 

instead of copying file.


On Linux (and probably on MacOS too) you can find folder with pip using

which pip3

eventually

whereis pip3

Upvotes: 1

Related Questions