在 Windows 中使用 python 和 Anaconda

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37918215/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 20:06:42  来源:igfitidea点击:

Using python with Anaconda in Windows

pythonwindowsnumpycmdanaconda

提问by The Dude

I have just installed Anaconda on my computer because I need to use Numpy. Well, when I use python I for some reason have to be in the same folder as python.exeand, of course, now that I want to use Anaconda I have to be in the Anaconda3\Scriptsfolder where python.exeisn't. This is a nightmare, how can I use anaconda with python on a windows computer? Why does it have to be so complicated?

我刚刚在我的电脑上安装了 Anaconda,因为我需要使用 Numpy。好吧,当我使用 python 时,出于某种原因,我必须在同一个文件夹中python.exe,当然,现在我想使用 Anaconda,我必须在不在的Anaconda3\Scripts文件夹中python.exe。这是一场噩梦,如何在 windows 计算机上使用 anaconda 和 python?为什么要这么复杂?

回答by Ian

I think you are referring to the command-line use of python?

我认为您指的是命令行使用python?

If you have admin priviliges on your machine you can add pythonto your environment variables, making it available in the console anywhere. (Sorry for different spellings, I am not on an english machine)

如果您的机器上有管理员权限,您可以添加python到您的环境变量中,使其在任何地方的控制台中都可用。(对不起,拼写不同,我不是在英语机器上)

  1. Press Shift+Pause("System")
  2. Click "Advanced System Options"
  3. Click "Environment variables"
  4. In the lower field with "System variables" there is a variable called PATH. Append the complete path to your python.exewithout the file to that by adding a ;behind the last path in the variable and then adding your path. Do not add any spaces!
  1. Shift+Pause(“系统”)
  2. 点击“高级系统选项”
  3. 点击“环境变量”
  4. 在带有“系统变量”的下方字段中,有一个名为PATH. python.exe通过;在变量的最后一个路径后面添加一个,然后添加您的路径,将没有文件的完整路径附加到该文件中。不要添加任何空格!

Example: C:\examplepath\;C:\Python27\

例子: C:\examplepath\;C:\Python27\

回答by Michael James Kali Galarnyk

When you install anaconda on windows now, it doesn't automatically add Python or Conda to your path.

当您现在在 Windows 上安装 anaconda 时,它不会自动将 Python 或 Conda 添加到您的路径中。

If you don't know where your conda and/or python is, you type the following commands into your anaconda prompt (it comes when you install anaconda)

如果您不知道 conda 和/或 python 在哪里,请在 anaconda 提示符中键入以下命令(安装 anaconda 时会出现)

enter image description here

在此处输入图片说明

Next, you can add Python and Condato your path by using the setx command in your command prompt. enter image description here

接下来,您可以使用命令提示符中的 setx 命令将Python 和 Conda添加到您的路径中。 在此处输入图片说明

Next close that command prompt and open a new one. You should now be able to use the python command. To do this you open a command prompt and type

接下来关闭该命令提示符并打开一个新的。您现在应该可以使用 python 命令了。为此,您打开命令提示符并键入

python nameofPythonfile.py

python nameofPythonfile.py

Source: https://medium.com/@GalarnykMichael/install-python-on-windows-anaconda-c63c7c3d1444

来源:https: //medium.com/@GalarnykMichael/install-python-on-windows-anaconda-c63c7c3d1444

回答by Jaxian

To be able to do that in the command line you just have to add Python and also the Anaconda3\Scripts directory to your system path.

为了能够在命令行中执行此操作,您只需将 Python 和 Anaconda3\Scripts 目录添加到您的系统路径中。

Here is a good tutorial on setting your path in Windows: http://www.computerhope.com/issues/ch000549.htm

这是在 Windows 中设置路径的好教程:http: //www.computerhope.com/issues/ch000549.htm