简体   繁体   中英

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.

So my problem is that I installed Ruby using home-brew, for some reason, this installation changed my default python site-package directory. Before I have Ruby, my terminal python will automatically call the site-package from the path '/Users/xxxxxx/canopy/lib/python2.7/site-packages'. However, it now will use '/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.

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'. Btw, my bash_profile and $PATH looks like this before: bash_profile之前之前的路径 and looks like this 现在bash_profile现在的路径

3 add the path '/Users/xxxxxx/canopy/lib/python2.7/site-packages' into sys.path, which look like this now:

在此处输入图片说明

But none of those worked. How can I make my terminal point to the path '/Users/xxxxxx/canopy/lib/python2.7/site-packages' now? 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 . Before doing anything, in terminal, start a new Python session and do

import sys
print sys.path

If the paths are of the form /Library/Python/2.7/site-packages/foo.egg , then just follow link

tl;dr

Basically add this to your 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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