简体   繁体   English

在Mac OSX上为python 3.4安装pip软件包管理器时出错

[英]Errors installing pip package manager for python 3.4 on Mac OSX

I'm trying to install pip for python 3.4. 我正在尝试为python 3.4安装pip。 Here's the error message that I get. 这是我收到的错误消息。

python: posix_spawn: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No such file or directory

The python version information of my system is hereunder: 我系统的python版本信息如下:

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 00:54:21) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

This is my path 这是我的路

export PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin/:$PATH
export PATH=/Library/Frameworks/Python.framework/Versions/3.4/bin/:$PATH
export PATH=/usr/bin:/usr/sbin:/bin:/usr/local/bin:/sbin:/opt/x11/bin:$PATH

How do I install pip and then virtualenv. 如何安装pip,然后安装virtualenv。 Any help will be appreciated. 任何帮助将不胜感激。

Since you are putting the Python 3.4 bin directory at the end of your PATH , running python in Terminal is resulting in /usr/bin/python being called, which is the system version 2.6. 由于将Python 3.4 bin目录放在PATH的末尾,因此在Terminal中运行python会导致调用/usr/bin/python ,这是系统版本2.6。 Try just running python and you'll see. 尝试只运行python ,您会看到的。

To fix it, set your PATH up like so: 要解决此问题,请按以下步骤设置您的PATH

export PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin/:/Library/Frameworks/Python.framework/Versions/3.4/bin/:/usr/bin:/usr/sbin:/bin:/usr/local/bin:/sbin:/opt/x11/bin:$PATH

2.7/bin contains a python executable, while 3.4/bin should also contain a python3 executable. 2.7/bin包含python可执行文件,而3.4/bin也应包含python3可执行文件。 Now, when you run python from the command prompt, the Python.org version of Python 2.7 will start up, and if you run python3 then version 3.4 will start. 现在,当您从命令提示符运行python时,Python 2.7的Python.org版本将启动,如果运行python3则3.4版本将启动。 Download get-pip.py from here , then run it using python3 . 此处下载get-pip.py ,然后使用python3运行它。 Depending on your system configuration, you may need to prefix the command with sudo (ie, sudo python3 get-pip.py ). 根据您的系统配置,您可能需要在命令前加上sudo (即sudo python3 get-pip.py )。

Python 3.4 already comes with venv , so you should be able to run pyvenv /path/to/virtual_env to set up a virtual environment. venv已随附Python 3.4,因此您应该能够运行pyvenv /path/to/virtual_env来设置虚拟环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM