如何修改mac os 10.10上的pip安装路径

时间:2014-12-25 22:28:19

标签: python django macos environment-variables pip

我想使用python3.4作为默认版本,并通过pip或easy_install将额外的软件包安装到python3。我在我的mac上安装了python3.3和python3.4。

要更改默认的python版本,aka python命令将转到python3.4而不是python2.7,我添加了一个名为.bash_aliases的文件,其中包含alias python='python',然后{ {1}}文件。该方法有效,直到我重新启动终端。此外,我将source添加到export PYTHONPATH="/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4/"然后.bash_profile,但版本没有变化。

我在source中设置了这些环境变量,但即使在谷歌搜索和尝试不同的策略之后也不知道如何改变。我.bash_profile中的一些行:

.bash_profile

export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/Library/Java/Home//bin"
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/directory-you-do-development-in
source /usr/local/bin/virtualenvwrapper.sh

我知道官方手册中有一个临时方式## # Your previous /Users/john/.bash_profile file was backed up as /Users/jonh/.bash_prof ile.macports-saved_2014-02-09_at_13:58:24## export PATH=/usr/local/bin:$PATH # MacPorts Installer addition on 2014-02-09_at_13:58:24: adding an appropriate PATH variable for u se with MacPorts. export PATH=/opt/local/bin:/opt/local/sbin:$PATH # Finished adapting your PATH environment variable for use with MacPorts. ## # Your previous /Users/john/.bash_profile file was backed up as /Users/john/.bash_prof ile.macports-saved_2014-02-09_at_14:02:11 ## # MacPorts Installer addition on 2014-02-09_at_14:02:11: adding an appropriate PATH variable for use with MacPorts. export PATH=/opt/local/bin:/opt/local/sbin:$PATH # Finished adapting your PATH environment variable for use with MacPorts. # Setting PATH for Python 3.4 # The orginal version is saved in .bash_profile.pysave export PATH=/Library/Frameworks/Python.framework/Versions/3.4/bin:$PATH ,但有没有办法永久更改安装路径?

1 个答案:

答案 0 :(得分:0)

您似乎安装了macport,因此选择Python版本的最简单方法是使用命令 port select : 首先,列出已安装的所有可用Python变体: port select --list python Wich会像这样给出这样的:

python的可用版本:     没有     python26苹果     python27(主动)     python27苹果     python34 然后,如果你想让python34成为默认的python版本: sudo port select --set python python34

你可以用pip做同样的事情: sudo port select --set pip pip34

您将避免使用别名,环境变量等处理自己的麻烦......