Python anaconda - Windows 中的路径环境变量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34030373/
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
anaconda - path environment variable in windows
提问by Alejandro Simkievich
I am trying to run python from the windows command prompt (windows 10). So the result is the typical one when the path environment variable is not configured
我正在尝试从 Windows 命令提示符(Windows 10)运行 python。所以结果就是没有配置path环境变量时的典型
c:\windows\system32>python
'python' is not recognized as an internal or external command, operable
program or batch file
however, I am not sure which is the right directory I should set up in the path variable.
但是,我不确定应该在路径变量中设置哪个目录是正确的。
I tried a few variations, and none of them work, including:
我尝试了一些变体,但都不起作用,包括:
c:\users\xxx\anaconda3
c:\users\xxx\anaconda3\Scripts
c:\users\xxx\anaconda3\libs\python34
and none of them works.
他们都没有工作。
Does anyone have experience with this particular system constellation (windows, anaconda). Thanks.
有没有人对这个特定的系统星座(windows,anaconda)有经验。谢谢。
采纳答案by Alejandro Simkievich
it turns out I was mistaken.
原来我错了。
Solution is: in anaconda (as well as in other implementations), set the path environment variable to the directory where 'python.exe' is installed.
解决方案是:在anaconda(以及其他实现)中,将路径环境变量设置为安装“python.exe”的目录。
As a default, the python.exe file in anaconda is in:
默认情况下,anaconda 中的 python.exe 文件位于:
c:\.....\anaconda
after you do that, obviously, the python command works, in my case, yielding the following.
在你这样做之后,显然,python 命令在我的情况下工作,产生以下内容。
python
Python 3.4.3 |Anaconda 2.2.0. (64|bit)|(default, Nov 7 2015), etc, etc
回答by fivef
C:\Users\<Username>\AppData\Local\Continuum\anaconda2
For me this was the default installation directory on Windows 7. Found it via Rusy's answer
对我来说,这是 Windows 7 上的默认安装目录。通过Rusy 的回答找到它
回答by KAMLESH KARKI
Instead of giving the path following way:
而不是以下列方式给出路径:
C:\Users\User_name\AppData\Local\Continuum\anaconda3\python.exe
Do this:
做这个:
C:\Users\User_name\AppData\Local\Continuum\anaconda3\
回答by Arman Fatahi
In windows 10 you can find it here:
在 Windows 10 中,您可以在这里找到它:
C:\Users\[USER]\AppData\Local\conda\conda\envs\[ENVIRONMENT]\python.exe
C:\Users\[USER]\AppData\Local\conda\conda\envs\[ENVIRONMENT]\python.exe
回答by Piyush Upadhyay
C:\Users\\Anaconda3
C:\用户\\Anaconda3
I just added above path , to my path environment variables and it worked. Now, all we have to do is to move to the .py script location directory, open the cmd with that location and run to see the output.
我刚刚将上面的 path , 添加到我的路径环境变量中并且它起作用了。现在,我们要做的就是移动到 .py 脚本位置目录,使用该位置打开 cmd 并运行以查看输出。
回答by Psychotechnopath
You could also just re-install Anaconda, and tick the option add variable to Path.. This will prevent you from making mistakes when editing environment variables. If you make mistakes here, your operating system could start malfunctioning.
您也可以重新安装 Anaconda,并勾选选项将变量添加到路径。这将防止您在编辑环境变量时出错。如果您在这里犯错,您的操作系统可能会开始出现故障。
回答by Chad Hamilton Frederick
The default location for python.exe should be here: c:\users\xxx\anaconda3
One solution to find where it is, is to open the Anaconda Prompt then execute:
python.exe 的默认位置应该在这里:c:\users\xxx\anaconda3
找到它所在位置的一种解决方案是打开 Anaconda Prompt 然后执行:
> where python
This will return the absolute path of locations of python eg:
这将返回 python 位置的绝对路径,例如:
(base) C:\>where python
C:\Users\Chad\Anaconda3\python.exe
C:\ProgramData\Miniconda2\python.exe
C:\dev\Python27\python.exe
C:\dev\Python34\python.exe
回答by prusswan
To export the exact set of paths used by Anaconda, use the command echo %PATH%
in Anaconda Prompt. This is needed to avoid problems with certain libraries such as SSL.
要导出 Anaconda 使用的确切路径集,请使用echo %PATH%
Anaconda Prompt 中的命令。这是避免某些库(如 SSL)出现问题所必需的。
Reference: https://stackoverflow.com/a/54240362/663028
回答by Matt
You can also run conda init
as below,
您也可以conda init
按如下方式运行,
C:\ProgramData\Anaconda3\Scripts\conda init cmd.exe
or
或者
C:\ProgramData\Anaconda3\Scripts\conda init powershel