python自带pip,哪个python带有哪个pip?

This is driving me crazy. I have tried to remove all the packages of python installed on mac os x el capitan and re-installed brew install python and pip. Here I have :

which pip

/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin/pip

and

which python

/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin/python

so using pip list

pip list

cycler (0.10.0)

matplotlib (1.5.1)

numpy (1.11.0)

pip (8.1.2)

python-dateutil (2.5.3)

pytz (2016.4)

setuptools (19.4)

six (1.10.0)

wheel (0.26.0)

However, when I run python, there is no module called numpy and matplotlib:

python

Python 2.7.11 (default, Jan 22 2016, 08:29:18)

[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import numpy

Traceback (most recent call last):

File "", line 1, in

ImportError: No module named numpy

>>> import matplotlib

Traceback (most recent call last):

File "", line 1, in

File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 122, in

from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_label

File "/usr/local/lib/python2.7/site-packages/matplotlib/cbook.py", line 33, in

import numpy as np

ImportError: No module named numpy

and this is my sys.path:

sys.path

['', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/site-packages/gtk-2.0']

解决方案

You can run pip with a specific version of Python by running it as a module. Command line arguments work just as if running directly from the command line. For example, try:

python -m pip list

If that still lists numpy it probably means there is something wrong with the numpy installation — i.e. the .egg file is there, but the module folder is not. To try and fix this you can use --force-reinstall with pip, e.g.

python -m pip install numpy --force-reinstall --upgrade

If that still doesn't work, you can resort to going to the folder reported by sys.path and deleting anything numpy related manually.

Since your pip setup seems messed up you might want to try reinstalling pip too!

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值