Python 2.7中的问题导入模块 [英] Trouble importing module in Python 2.7
问题描述
我的Mac计算机具有Python 3.6和Python 2.7,例如,通过执行例行的pip install和pip3 install,我已经成功安装了numpy,scipy和matplotlib等基本模块.我的Python 3.6在Anaconda-Jupiter-Notebook,IDLE和Terminal中完全可以很好地工作,而Python 2.7仅在Terminal中起作用,而在IDLE中则没有.
My Mac computer has Python 3.6 and Python 2.7 and I have successfully installed the basic modules such as numpy, scipy and matplotlib, for example, by doing the routine pip install and pip3 install. My Python 3.6 works totally well in Anaconda-Jupiter-Notebook, IDLE and Terminal, while Python 2.7 works only in terminal but not in IDLE.
然后进行我尝试过的版本检查
Then for version check I tried
pip --version
返回: 来自/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip(python 2.7)的pip 10.0.1
Returning: pip 10.0.1 from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip (python 2.7)
pip3 --version
返回: 来自/Users/son520804/anaconda3/lib/python3.6/site-packages/pip(python 3.6)的pip 10.0.1
Returning: pip 10.0.1 from /Users/son520804/anaconda3/lib/python3.6/site-packages/pip (python 3.6)
然后
which python2
返回: /Library/Frameworks/Python.framework/Versions/2.7/bin/python2
Returning: /Library/Frameworks/Python.framework/Versions/2.7/bin/python2
which pip2
返回: /Library/Frameworks/Python.framework/Versions/2.7/bin/pip2
Returning: /Library/Frameworks/Python.framework/Versions/2.7/bin/pip2
如何解决此问题并使Python 2.7空闲状态导入模块?非常感谢您的帮助.
How could I resolve this issue and enable the Python 2.7 idle to import the modules? Much appreciated for your help.
推荐答案
也许您的pip
是pip3
的别名.通过pip --version
找到它,如果是,则将python 2.7
的软件包安装为pip2.7 install matplotlib
Perhaps your pip
is an alias to pip3
. Find it out by pip --version
and if so install packages for python 2.7
as pip2.7 install matplotlib
这篇关于Python 2.7中的问题导入模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!