简体   繁体   中英

'python' points to anaconda installation

I've installed anaconda, but I still want to use python as normal within a Terminal window ( zsh ). At the moment, running which python shows /Users/USERNAME/opt/anaconda3/bin/python .

I don't want this command to point to my anaconda installation. I want to use python as I have in the past, and for it to point to my python 2.7 installation ( /usr/bin/python ).

The same issue is present with pip and with python3 . How do I change these paths back to their default locations?

I want to start out by saying I personally have never used Anaconda, but I have many friends who have and they always seem to wind up getting into hot water as far as configurations go. If you don't need the data-science specific tools that Anaconda offers (most of which I imagine you can get just as easily by using pip install <package_name> ), then I STRONGLY urge you to not use Anaconda. I would suggest you instead use homebrew to install python 3.7 and leave the system version of python 2.7 alone... Anyways...

I recently fixed an issue similar to the one you're describing for a friend. I ended up deleted his anacaonda build and reinstalling fresh from homebrew (link: https://brew.sh/ ), so this is how I helped him and hopefully this will help you too.

Firstly, I would check the configuration of your ~/.bash_profile (or potentially ~/.bashrc ) file. Comment out any lines you find that have to do with Anaconda by preceding with the # character. I believe when anaconda installs it puts the location of the anaconda-version-of-python higher in the PATH hierarchy, therefore you computer sees it first before it has the chance to look in /usr/bin ...

Secondly, you need to move the anaconda-python to the trash... I would start by trashing the whole '/Users/USERNAME/opt/anaconda3' directory. If memory serves me correctly anaconda stores other python related things in the /MacitoshHD/Library/Frameworks directory, but don't quote me on that. I would advise looking there and trashing whatever seems to be related to the anaconda install.

After that, in a new terminal (so that your PATH refreshes), I installed homebrew, and then ran the command brew install python3 to install python3. I think perhaps I ran the command recommended in the installer output, something like "brew link python3" to symlink python3 where it needs to be linked after the installation.

Finally, everything is done python2 and python3 are installed and working with no issues. python2 is the system default version and python3 is the homebrew installed version. Feel free to ask any questions and I will try to help more, hopefully those instructions will get you started though.

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