Compatibility of Pyenv/virtualenv and Anaconda under Mac

Source: Internet
Author: User
Tags virtualenv

http://blog.csdn.net/vencent7/article/details/76849849

The pyenv and pyenv-virtualenv that you have been using to manage different Python environments. Yesterday my friend recommended me to install a Anaconda (through the official website download installs with the graphical interface Anaconda Navigator version, is not through the pyenv installs), the result installs appears to be not very compatible with the original pyenv, searches on the net a bit, Have encountered a similar situation: Https://stackoverflow.com/questions/40944277/pyenv-and-anaconda-issue-with-export-path

After trying, I found the following solution:

Solve the PATH environment variable problem

Anaconda installation will be in .bash_profile the last line to add their own PATH to the front, it is because of this cause pyenv failure (pyenv is also by adding their PATH to the most "hijack" python and other commands to achieve multi-version management), Because according to the official installation instructions,Pyenv's several lines of command should be placed at .bash_profile the end .

Therefore, edit the. Bash_profile so that the pyenv command is placed after the Anaconda:

# added by Anaconda3 4.4.0 installerexport path= "/users/frederic/anaconda/bin:< Span class= "hljs-variable" > $PATH "# pyenvexport PYENV_ROOT=< Span class= "hljs-string" > " $HOME/.pyenv" export PATH= " $PYENV _root/bin: $PATH" eval  "$ (pyenv init-)" eval  "$ (pyenv virtualenv-init- )" 
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
Solve the problem of virtualenv identifying anaconda virtual Environments

With the above steps, PYENV/VIRTUALENV has a higher priority than anaconda, so if you run the version you see should be the version python -version specified by pyenv instead of the Anaconda version.

However, how do I run the anaconda version of Python?

    1. If you have not created an environment and have only the default root, we need to create a new environment from the Conda or Anaconda Navigator graphical interface first.
    2. A soft link to the Environment folder .pyenv/versions that you just created, which allows pyenv/virtualenv to recognize the environment created by Anaconda (Anaconda that is installed through pyenv should be recognized directly, but my anaconda is installed independently, so the pyenv is not detected):ln -s ~/anaconda/envs/anaconda_env ~/.pyenv/versions/anaconda_env
    3. Now enter the PYENV versions command should be able to see the anaconda environment, can be virtualenv activate/deactivate command or PYENV command pyenv shell/local/glocal [env_name] switch version

Compatibility of Pyenv/virtualenv and Anaconda under Mac

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.