为什么安装不了python3 get pip,Python3找不到pip3安装的模块

I'm having problems with python3. For some reason that I cannot figure out, the modules available in python3 are not the same as the ones installed via pip3.

Running pip3 list in a Terminal returns:

DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.

nltk (3.2.2)

numpy (1.12.0)

pandas (0.19.2)

pip (9.0.1)

python-dateutil (2.6.0)

pytz (2016.10)

setuptools (25.2.0)

six (1.10.0)

wheel (0.29.0)

Running this script to see what modules python3 has available returns:

['cycler==0.10.0', 'matplotlib==1.5.3', 'nltk==3.2.1', 'numpy==1.11.2', 'pip==9.0.1', 'pyparsing==2.1.10', 'python-dateutil==2.6.0', 'pytz==2016.7', 'setuptools==18.2', 'six==1.10.0']

These two are not the same and I can't tell why. nltk, for example, has an older version. pandas is missing.

I've installed python via homebrew and I'm running scripts via Textmate2. However, I have the same problem when I run code in terminal, via python3. Both pip3 and python3 are installed in /usr/local/bin/:

$ which python3 pip3

/usr/local/bin/python3

/usr/local/bin/pip3

And that's also the version python3 is using:

>>> import sys, os

>>> os.path.dirname(sys.executable)

'/usr/local/bin'

If someone could help me figure out why this is the case, and how I can fix it, I would very much appreciate the help.

解决方案

Look at the first line of the pip3 script.

The first line (starting with #! should point to the same executable as the symbolic link for python 3:

> head -n 1 /usr/local/bin/pip

#!/usr/local/bin/python3.6

> ls -ld /usr/local/bin/python3

lrwxr-xr-x 1 root wheel 9 Dec 25 22:37 /usr/local/bin/python3@ -> python3.6

If this is not the case, deinstall pip and install it again with the correct Python version.

EDIT:

If you really want to make sure that you're using the the right Python with pip, then call it as a module like this:

python3.7 -m pip list

If you get the error No module named pip, then pip is not installed for this version of python.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值