【发布时间】:2015-08-05 19:14:28
【问题描述】:
我刚刚做了一个
sudo pip install matplotlib
效果很好。那么
sudo pip install matplotlib
详情:
$sudo pip install mpld3
Downloading/unpacking mpld3
Downloading mpld3-0.2.tar.gz (1.1MB): 1.1MB downloaded
Running setup.py (path:/private/tmp/pip_build_root/mpld3/setup.py) egg_info for package mpld3
Installing collected packages: mpld3
Running setup.py install for mpld3
Successfully installed mpld3
Cleaning up...
所以mpld3也安装好了。
由于某种原因 matplotlib 出现在 python 中,但没有出现在 mpld3 中:
In [3]: import matplotlib.pyplot as plt
In [4]: plt.plot([3,1,4,1,5], 'ks-', mec='w', mew=5, ms=20)
Out[4]: [<matplotlib.lines.Line2D at 0x103ab4d10>]
In [5]: plt.show()
工作正常..
但是:
In [6]: import mpld3
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-6-25a6968c2f16> in <module>()
----> 1 import mpld3
ImportError: No module named mpld3
是否有必要更新,例如PYTHONPATH 或其他一些环境变量?
更新回答@infinity 关于 pip 与 ipython 版本的(好)问题:
$which pip
/usr/local/Cellar/python/2.7.8_2/bin/pip
18:20:42/lightbox2 $which ipython
/usr/local/bin/ipython
18:20:45/lightbox2 $which python
/usr/local/Cellar/python/2.7.8_2/bin/python
18:23:58/lightbox2 $sudo pip install ipython
Password:
Requirement already satisfied (use --upgrade to upgrade): ipython in /Library/Python/2.7/site-packages
Cleaning up...
【问题讨论】:
-
键入:
which pip和which ipython。告诉我们答案:) -
@Infinity 我知道你要去哪里:ipython 来自 /usr/local/bin 而 python 来自 brew。那么,我需要弄清楚如何将 ipython 与 brew python 连接起来。
-
@Infinity 请查看更新的 OP
-
使用ipython,能不能写“import sys;sys.executable”?
-
@Infinity 是的,它是不正确的 (/usr/bin/python) 。我在这里看到的唯一建议stackoverflow.com/questions/9386048/… 需要更新 ipython 脚本。太丑了。