如何将anaconda添加到PATH? [英] How to add anaconda to PATH?

查看:1911
本文介绍了如何将anaconda添加到PATH?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在系统(Mac OS)上下载了Anaconda,仅出于使用Spyder在Python中进行编码的目的.我遇到了两个问题,对于比我更适合计算机的人来说,可能很容易解决.我很乐意提供帮助!

I downloaded Anaconda on my system (Mac OS), for now solely for the purpose of using Spyder to code in Python. I am having two issues, which are probably easy to solve for someone who is more fit with computers than me. I would be glad for help!

  1. 是否将anaconda添加到PATH,如果是,如何添加?

此处的线程中,我获得了更新方面的帮助Anaconda和Spyder,因为执行线conda update anacondaconda update spyder将导致zsh: command not found.显然,这与anaconda没有添加到我的PATH有关.在该线程中,提供了一种解决方法,而没有将anaconda添加到我的路径中.但是,在更新之前,我必须每次都运行一个命令行.

In this thread here I got help with updating Anaconda and Spyder, since executing the lines conda update anaconda and conda update spyder would result in zsh: command not found. Apparently this has to do with anaconda not being added to my PATH. In that thread I was offered a workaround without adding anaconda to my path. However I would have to run a commandline everytime before I update it.

现在,我完全承认,我什至不知道将anaconda添加到我的路径意味着什么.而且我不知道添加它的优缺点是什么.但我有点想添加它,这样我不必每次更新时都查找并运行此命令行.有人可以解释一下我是否应该将anaconda添加到PATH中,如果这样,怎么做?

Now, I fully admit, that I don't even know what it means to add anaconda to my path. And I don't know what are the pros and cons of adding it, or not. But I kind of would like to add it, such that I don't have to look up and run this command line every time when I update. Could someone please explain if I should add anaconda to PATH, and if so, how?

  1. 什么使用python发行版?

我对系统上的python发行版感到非常困惑.

I am getting very confused with python distributions on my system.

  • 在Spyder底部的面板中,我看到它使用的是Python 3.7.4 ..
  • 在Spyder的IPython控制台中,我看到它使用的是Python 3.7.0.
  • 如果我在终端中运行python --version,我会得到Python 2.7.16
  • 如果我在终端中运行python3 --version,我会得到Python 3.7.3
  • In the panel at the bottom of Spyder I see, that it uses Python 3.7.4..
  • In the IPython console of Spyder I see that it uses Python 3.7.0.
  • If I run python --version in a terminal I get Python 2.7.16
  • If I run python3 --version in a terminal I get Python 3.7.3

为什么我的系统上所有这些不同的版本?如果我在Spyder中开发脚本,然后想从终端运行它,那么我当然想使用与Spyder使用的Python解释器相同的python解释器运行它.我如何确定是这种情况?例如,我是否通过python script.py,"python3 script.py"或其他命令行运行名为script.py的脚本?

Why are all these different versions on my system? If I develop a script in Spyder, and then want to run it from the terminal, then I of course would like to run it with the same python interpreter as the one Spyder uses. How can I make sure this is the case? Do I for example run a script named script.py by python script.py, by `python3 script.py´, or by yet another command line?

我什至不确定pythonpython3是否调用了anaconda随附的发行版,因为当我运行which pythonwhich python3时,我会在安装anaconda的情况下得到/usr/bin/python或用户/usr/bin/python3.在Users/opt/<my_username>/anaconda3/bin中.

I am not even sure if python or python3 calls the distributions which came with anaconda, since when I run which python or which python3 I get /usr/bin/python or user /usr/bin/python3, while anaconda is installed in Users/opt/<my_username>/anaconda3/bin.

因此,如果有人也能为我消除雾气,那就太好了! :)

So if someone could clear the fog here for me please as well, that would be great! : )

感谢帮助!

推荐答案

macOS附带了Python v(大多数情况下是2.x),并且您已经为另一个版本安装了anaconda. 要检查这一点,您可以先运行以下命令:

A Python v (most of the time 2.x) comes with macOS and you have installed anaconda for the other one version. to check this you can first run this command:

conda env list

如果您已将python2x安装为新的环境,它将显示为:

if you have installed python2x as a new env it will show up as:

# conda environments:
#
base                  *  /Users/your_user/Applications/anaconda3
py2                      /Users/your_user/Applications/anaconda3/envs/py2

如果您仅看到'base'(对我来说是anaconda3,所以是python 3.x),那么它说您的macOS带有python2.x(或相反). 通常,以下命令显示您的默认python版本:

if you only see 'base' (which is for me is anaconda3 so python 3.x) then it says that you had python2.x with your macOS ( or the reverse). Normally the below command shows your default python version:

    python --version
output (for me): Python 3.7.6

其中显示了Anaconda的版本. 如果要使用另一个,则可以 1)通过在这里使用我的答案来更改此方法:如何将默认的python3设置为python3.7?

Which shows the version you have with your Anaconda. If you want to use the other one, you can either 1) change this by using my answer here: How to set the default python3 to python3.7?

2),或者您可以在anaconda环境中添加新的"env"(如果在上面,您只能看到"base").此处提到了说明: https://docs.conda. io/projects/conda/en/latest/user-guide/tasks/manage-environments.html

2) or you can add a new "env" to your anaconda environments (if in the above you see only 'base'). The instructions are mentioned here: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html

这篇关于如何将anaconda添加到PATH?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆