Python 使用pip安装时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31498495/
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
Error when installing using pip
提问by lcm
Not sure whats going on here but I am getting an error every time I try to install something using pip I get the following error:
不确定这里发生了什么,但是每次尝试使用 pip 安装某些东西时都会出现错误,我收到以下错误:
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/b0/5843zgyj1yz3b8q2l7wrtj8h0000gn/T/pip-build-V4hy8S/PySocks/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/b0/5843zgyj1yz3b8q2l7wrtj8h0000gn/T/pip-bIOl7C-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/b0/5843zgyj1yz3b8q2l7wrtj8h0000gn/T/pip-build-V4hy8S/PySocks
命令 "/usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/b0/5843zgyj1yz3b8q2l7wrtj8h0000gn/T/pip-build-V4hy8S/PySocks/setup.py';exec(compile(getattr) (tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/b0 /5843zgyj1yz3b8q2l7wrtj8h0000gn/T/pip-bIOl7C-record/install-record.txt --single-version-externally-managed --compile" 失败,错误代码为 1 在 /private/var/folders/b0/5843zgyj1yz70wlgnTgnT构建-V4hy8S/PySocks
采纳答案by Dusty Boshoff
Seems that your PiP can't access Setuptools as per the "import setuptools" in the error. Try the below first then try running your pip install again.
根据错误中的“导入设置工具”,您的画中画似乎无法访问设置工具。首先尝试以下操作,然后再次尝试运行 pip install。
sudo pip install -U setuptools
Solution from Github Issue
来自Github 问题的解决方案
回答by Astik Anand
Try
尝试
sudo pip install -U setuptools
须藤 pip install -U setuptools
If this doesn't solve your problem then
如果这不能解决您的问题,那么
Firstly, you need the python-dev package because Pillow needs compile headers defined.
首先,你需要 python-dev 包,因为 Pillow 需要定义编译头。
sudo apt-get install python-dev
须藤 apt-get install python-dev
On Ubuntu 14.04 you need few extra packages to get pillow working. Install all of them with the command:
在 Ubuntu 14.04 上,你需要一些额外的包来让枕头工作。使用以下命令安装所有这些:
sudo apt-get install libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk
sudo apt-get install libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk
回答by CodeManga
Launch the command prompt with 'run as administrator' rights before installing. then try the script -
安装前以“以管理员身份运行”权限启动命令提示符。然后尝试脚本 -
pip install package_name_here
if error is thrown,then import setup tools
如果抛出错误,则导入设置工具
pip install -U setuptools
if again error thrown then upgrade your pip installer using this script(personally worked for me)
如果再次抛出错误,则使用此脚本升级您的 pip 安装程序(亲自为我工作)
python -m pip install --upgrade pip
回答by Ahmed Mohamed
first run as superuser:
首先以超级用户身份运行:
sudo su
then :
然后 :
pip install PyOpenGL PyOpenGL_accelerate
回答by Hans Goldman
If you get this error on Windows, like I did, then just run the command-line tool (cmd.exe or Powershell) as Administrator and try again.
如果您在 Windows 上遇到此错误,就像我一样,那么只需以管理员身份运行命令行工具(cmd.exe 或 Powershell)并重试。
回答by leastgrebe
I had the same problem on Windows Git Bash but installing setuptools did not fix it. Then I noticed another error message further up:
我在 Windows Git Bash 上遇到了同样的问题,但安装 setuptools 并没有解决它。然后我注意到另一条错误消息:
building 'twisted.test.raiser' extension error: Microsoft Visual C++ 14.0 is
required. Get it with "Microsoft Visual C++ Build Tools":
http://landinghub.visualstudio.com/visual-cpp-build-tools
That link was dead but ultimately this page had a link to the correct download: https://wiki.python.org/moin/WindowsCompilers
该链接已失效,但最终此页面有一个指向正确下载的链接:https: //wiki.python.org/moin/WindowsCompilers
I installed Microsoft Build Tools for Visual Studio 2017 and that resolved it.
我安装了 Microsoft Build Tools for Visual Studio 2017 并解决了它。
回答by Skanda Shastry
It majorly depends on the type of packages you suppose to install. Frequently its failing due to the missing of libsasl2-deva packagefor authentication abstraction library which use in the Ubuntu version
这主要取决于您想安装的软件包类型。通常由于其未能失踪 libsasl2-DEV一个包进行认证抽象库,使用Ubuntu的版本
First, install:
首先,安装:
sudo apt-get install libsasl2-dev
须藤 apt-get 安装 libsasl2-dev
then run:
然后运行:
pip install <<\package_name>>
pip 安装 <<\package_name>>