Python 导入错误:尝试安装软件包时没有名为 pip 的模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22391580/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ImportError: No module named pip when trying to install packages
提问by Ciaran
Have a fresh install of Ubuntu 13.10 with PyCharm and when setting up the python interpreter I selected 'install setuptools', then 'install pip'. Now if I try and do anything with pip I get the following:
使用 PyCharm 全新安装 Ubuntu 13.10,在设置 python 解释器时,我选择了“安装 setuptools”,然后选择“安装 pip”。现在,如果我尝试用 pip 做任何事情,我会得到以下信息:
ciaran@ciaran-desktop:~/pycharm/bin$ pip
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 357, in load_entry_point
"""Does the package's distribution contain the named metadata?"""
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2394, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2108, in load
ImportError: No module named pip
I have tried on python 2.7.5 and 3.3.2 and both yield the same results.
我已经尝试过 python 2.7.5 和 3.3.2 并且都产生了相同的结果。
Edit: The above output is from the terminal. PyCharm outputs the following:
编辑:以上输出来自终端。PyCharm 输出以下内容:
Error: Python package management tool 'pip' not found
采纳答案by Apalala
I found that on Ubuntu, pip will not always set read and execute permissions for the modules it installs. My solution is to always run this shell script:
我发现在 Ubuntu 上,pip 并不总是为其安装的模块设置读取和执行权限。我的解决方案是始终运行此 shell 脚本:
sudo chmod -R a+rX /usr/lib/python*/dist-packages/
sudo chmod -R a+rX /usr/local/lib/python*/dist-packages/
sudo chmod a+rX /usr/bin/*
sudo chmod a+rX /usr/local/bin/*
回答by Johan84
Download the file get-pip.py from the pip-website (http://pip.readthedocs.org/en/stable/installing/). Open the terminal, cd in to the folder where you placed get-pip.pyand run:
从 pip 网站 ( http://pip.readthedocs.org/en/stable/installing/)下载文件 get-pip.py 。打开终端,cd 到你放置get-pip.py的文件夹 并运行:
sudo python3 get-pip.py
须藤 python3 get-pip.py
Open pycharm and install desired package...
打开 pycharm 并安装所需的包...

