問題描述
我在我的系統 (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!
- 是否將 anaconda 添加到 PATH,如果是,如何添加?
在 此線程中,我得到了更新方面的幫助Anaconda 和 Spyder,因為執行 conda update anaconda
和 conda update spyder
行會導致 zsh: command not found
.顯然,這與 anaconda 未添加到我的路徑有關.在那個線程中,我得到了一種解決方法,而無需將 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?
- 哪個 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 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?
我什至不確定 python
或 python3
是否調用 anaconda 附帶的發行版,因為當我運行 which python
或 which python3
我得到 /usr/bin/python
或用戶 /usr/bin/python3
,而 anaconda 安裝在 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?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!