[英]Python default site-package directory changed after installing Ruby
I have spent a few hours trying to solve this problem but didn't manage yet. 我已经花了几个小时试图解决这个问题,但是还没有解决。 I figure my question is a bit specific to my own mac configuration and I need a more detailed instruction.
我认为我的问题是特定于我自己的mac配置,我需要更详细的说明。
So my problem is that I installed Ruby using home-brew, for some reason, this installation changed my default python site-package directory. 所以我的问题是我使用自制软件安装了Ruby,出于某种原因,此安装更改了默认的python site-package目录。 Before I have Ruby, my terminal python will automatically call the site-package from the path '/Users/xxxxxx/canopy/lib/python2.7/site-packages'.
在使用Ruby之前,我的终端Python将自动从路径“ /Users/xxxxxx/canopy/lib/python2.7/site-packages”调用站点包。 However, it now will use '/Library/Python/2.7/site-packages'.
但是,它现在将使用'/Library/Python/2.7/site-packages'。 I tried three different ways to solve this issue but all failed:
我尝试了三种不同的方法来解决此问题,但均失败了:
1 use Canopy Terminal like this Set Canopy Preference , but this method point to another directory '/Applications/Canopy.app/appdata/canopy-1.5.2.2785.macosx-x86_64/Canopy.app/Contents/lib/python2.7/site-packages', which is not i want either. 1像这样设置Canopy首选项来使用Canopy Terminal,但是此方法指向另一个目录'/Applications/Canopy.app/appdata/canopy-1.5.2.2785.macosx-x86_64/Canopy.app/Contents/lib/python2.7/site -packages',这也不是我想要的。
2 change the bash_profile like this amend path , but by just putting the # in every line of the bash_profile, it still use directory '/Library/Python/2.7/site-packages'. 2像这样的修改路径来更改bash_profile,但是只需将#放在bash_profile的每一行中,它仍然使用目录'/Library/Python/2.7/site-packages'。 Btw, my bash_profile and $PATH looks like this before:
顺便说一句,我的bash_profile和$ PATH之前看起来像这样:
and looks like this
看起来像这样
3 add the path '/Users/xxxxxx/canopy/lib/python2.7/site-packages' into sys.path, which look like this now: 3将路径'/Users/xxxxxx/canopy/lib/python2.7/site-packages'添加到sys.path中,现在看起来像这样:
But none of those worked. 但是这些都不起作用。 How can I make my terminal point to the path '/Users/xxxxxx/canopy/lib/python2.7/site-packages' now?
我如何使我的终端现在指向路径“ /Users/xxxxxx/canopy/lib/python2.7/site-packages”? Or ultimately, what should I do to clean up those different site-packages and use the one I only need?
或者最终,我应该怎么做才能清理那些不同的站点包并使用我只需要的站点包?
Thank you for any help! 感谢您的任何帮助!
On a mac by default the path is /Library/Python/2.7/site-packages/foo.egg
. 在Mac上,默认情况下,路径为
/Library/Python/2.7/site-packages/foo.egg
。 Before doing anything, in terminal, start a new Python session and do 在执行任何操作之前,请在终端中启动一个新的Python会话并执行
import sys
print sys.path
If the paths are of the form /Library/Python/2.7/site-packages/foo.egg
, then just follow link 如果路径的格式为
/Library/Python/2.7/site-packages/foo.egg
,则只需/Library/Python/2.7/site-packages/foo.egg
链接
tl;dr tl; dr
Basically add this to your bash_profile
, 基本上将其添加到您的
bash_profile
,
source [...] /activate
VIRTUAL_ENV_DISABLE_PROMPT=1 source [...] activate
I found the solution: 我找到了解决方案:
added to the bash_profile this line " export PATH="$HOME/canopy/bin:$PATH" ", and uncomment all other lines in bash_profile. 在bash_profile中添加以下行“ export PATH =“ $ HOME / canopy / bin:$ PATH”“,并取消注释bash_profile中的所有其他行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.