简体   繁体   English

OS X“which python”指向python2.7而不是Anaconda python3.9

[英]OS X "which python" points to python2.7 instead of Anaconda python3.9

I factory reset my MacBook and set up everything new to get rid of the multiple python version chaos I had on my old laptop.我将我的 MacBook 恢复出厂设置并设置了所有新的东西,以摆脱我在旧笔记本电脑上遇到的多个 python 版本的混乱。

Only thing I have installed atm is Anaconda.我唯一安装 atm 的是 Anaconda。 I created a new conda environment with python 3.9 and activated it in my zsh Terminal.我用 python 3.9 创建了一个新的 conda 环境,并在我的 zsh 终端中激活了它。

Still when I type "which python" it shows "/usr/bin/python" containing the MacBook standard Python2.7 version.当我输入“which python”时,它仍然显示包含 MacBook 标准 Python2.7 版本的“/usr/bin/python”。

How can I make environments use their own dedicated version?如何让环境使用自己的专用版本?

Edit for Code:编辑代码:

conda activate myenvname
which python

Trying to access the folder where the anaconda python should be leads to尝试访问 anaconda python 所在的文件夹会导致

cd: no such file or directory: /Users/marcus/anaconda/bin

When you install anaconda through the terminal it provides an option to prepend anaconda to the system path.当您通过终端安装 anaconda 时,它提供了一个将 anaconda 添加到系统路径的选项。 make sure to choose yes.确保选择是。 If you don't, you'll need to provide the full path to your anaconda installation when activating an environment, as in:如果不这样做,则在激活环境时需要提供 anaconda 安装的完整路径,如下所示:

source <path to conda>/bin/activate
conda init

You'll need to do this in each shell session.您需要在每个 shell 会话中执行此操作。 Alternatively, you can use the anaconda terminal.或者,您可以使用 anaconda 终端。

To fix this, Anaconda does not recommend fixing your path manually.要解决此问题,Anaconda 不建议手动修复您的路径。 I think this is because there are a number of things anaconda does when setting up your shell if you choose "yes".我认为这是因为如果你选择“是”,anaconda 在设置你的 shell 时会做很多事情。 Instead, the recommended fix is to uninstall and re-install anaconda (and pick yes this time ;)).相反,建议的修复方法是卸载并重新安装 anaconda(这次选择是;))。

See the Anaconda docs for more information.有关更多信息,请参阅Anaconda 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果 openmesh 和 igl 库都不适用于 python2.7 或 python3.9,我该如何使用 Python 中的这些库? - How do I use openmesh and igl libraries in Python if both are not available for python2.7 or python3.9? 如何在 mac os x 上将 gunicorn 与 python3.8 而不是 python3.9 一起使用? - How can I use gunicorn with python3.8 instead of python3.9 on mac os x? 将消息从 python2.7 记录到 python3.9,反之亦然 - logging message from python2.7 to python3.9 vice versa 在centos 6上安装了Python2.7,现在pip指向Python2.7而不是Python版本 - Installed Python2.7 on centos 6 and now pip points to Python2.7 instead of Python version 在 macOS Sierra 中,如何配置 AWS CLI 以使用 Python3.x 而不是操作系统默认的 Python2.7? - In macOS Sierra, How Configure AWS CLI to Use Python3.x Instead of the OS Default Python2.7? “python3”正在执行“python3.8”而不是“python3.9” - “python3” is executing “python3.8” instead of “python3.9” 如何在spyder,jupyter和qtconsole中打开python2.7。 从蟒蛇安装了蟒蛇的Anaconda Navigator? (OS X) - How open python2.7 in spyder, jupyter, qtconsole. from Anaconda Navigator installed with python3? (OS X) 为anaconda python2.7安装PIL - Installing PIL for anaconda python2.7 Python3.9中的str格式化 - Str formatting in Python3.9 更新:在Python2.7中枚举而不是求和 - UPDATE: Enumerating instead of summing in Python2.7
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM