在Windows 10专业版上设置python

问题描述 投票:2回答:2

已经设置了Python 3.5和Python 2.7.11,但命令提示符都没有识别它们。也有下载pip.py,并且命令提示符无法识别它。已将PATH设置为C:\Python34;C:\Python34\Lib\site-packages\;C:\Python34\Scripts\;

并且还通过安装提示将Python 3.5添加到PATH。该计算机是戴尔,是Windows 10专业版计算机。

'python' is not recognized as an internal or external command, operable program, or batch file.

'pip' is not recognized as an internal or external command, operable program, or batch file.

python-2.7 path pip windows-10 python-3.5
2个回答
0
投票

我认为你必须创建一个名为PYTHONPATH的变量,请按照以下步骤操作

导航到My Computer > Properties > Advanced System Settings > Environment Variables >

然后在系统变量下创建一个名为PythonPath的新变量。

在这个变量包括C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk;C:\other-foolder-on-the-path

(没有额外的空间)

enter image description here

如果有人在那里上面没有工作,那么请用C:\Python27附加到你的PATH然后它肯定会工作

有关完整的详细信息,请访问document链接


0
投票

你修改后检查了路径了吗?您可能需要关闭并重新打开控制台窗口,甚至重新启动以更新环境变量。

相反,尝试py,这是Python启动器。它应该安装在路径中已经存在的C:\ Windows中。这是安装过程中的一个选项(下面对话框底部的常见选项)。将Python添加到路径也是一种选择,但安装两个版本只会使路径中的第一个工作。

enter image description here

它允许您选择要运行的Python版本:

py         # Run default python version...PY_PYTHON env. var can override this.
py -3      # Run the latest Python3 found on the system.
py -2      # Run the latest Python2 found on the system.
py -2.7    # Specifically run Python 2.7.
py -2.7-32 # Specifically run 32-bit Python 2.7 on a 64-bit system.

您还可以在脚本顶部添加#!python3注释,并在资源管理器中双击该文件将使用该版本的Python。

见:Python Launcher for Windows

© www.soinside.com 2019 - 2024. All rights reserved.