[英]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.