So I'm trying python 2.7 on my Windows. It is running Windows 8. I cannot add it to my path. I've done the usual: using the advanced system settings, environment variables, adding C:\Python27
in system variables.
所以我在Windows上尝试python 2.7。它正在运行Windows 8。我不能把它加到我的路径上。我已经完成了通常的工作:使用高级系统设置,环境变量,在系统变量中添加C:\Python27。
However, when I type Python in command prompt it says 'python is not recognized ..'
然而,当我在命令提示符中输入Python时,它说“Python不被识别”。
10 个解决方案
#1
60
I think that the essence of this question is how to install Python and be able to use it from the command line. The steps below show how to get all that working. Check that you didn't miss anything:
我认为这个问题的本质是如何安装Python并能够从命令行使用它。下面的步骤展示了如何实现所有这些工作。检查你没有错过任何东西:
- From https://www.python.org/download/releases/2.7.6 download appropriate Python 2.7.6 Windows Installer. (If that link doesn't work, check https://www.python.org/downloads/)
- 从https://www.python.org/download/releases/2.7.6下载适当的Python 2.7.6 Windows安装程序。(如果该链接不起作用,请检查https://www.python.org/downloads/)
- Run the file
- 运行该文件
- Select install for all users or install just for me, click Next
- 为所有用户选择安装或为我安装,单击Next。
- You'll see it installs under the C:\Python27 folder, click Next
- 您将看到它安装在C:\Python27文件夹下,单击Next。
- Click Next again for the 'Customize Python' step
- 再次单击“定制Python”步骤。
- Click Finish
- 单击Finish
- Open Control Panel, then System
- 打开控制面板,然后系统。
- Click 'Advanced system settings' on the left
- 点击左边的“高级系统设置”。
- Click the 'Environment Variables' button
- 点击“环境变量”按钮。
- Under 'System variables' click the variable called 'Path' then the 'Edit...' button. (This will set it for all users, you could instead choose to edit the User variables to just set python as a command prompt command for the current user)
- 在“系统变量”下点击“Path”变量,然后“编辑…””按钮。(这将为所有用户设置它,您可以选择编辑用户变量,将python设置为当前用户的命令提示命令)
- Without deleting any other text, add
C:\Python27;
(include the semi-colon) to the beginning of the 'Variable value' and click OK. - 不删除任何其他文本,添加C:\Python27;(包括分号)到“变量值”的开头,然后单击OK。
- Click OK on the 'Environment Variables' window.
- 在“环境变量”窗口中单击OK。
Open a new command prompt window type python
, you will have python running in the command prompt. Note: command prompt windows open prior to setting the Environment Variable will not have the python command available.
打开一个新的命令提示窗口类型python,您将在命令提示符中运行python。注意:在设置环境变量之前,命令提示窗口打开不会有python命令可用。
#2
5
System variables usually require a restart to become effective. Does it still not work after a restart?
系统变量通常需要重新启动才能生效。重启后还不工作吗?
#3
4
Easiest way is to open CMD or powershell as administrator and type
最简单的方法是打开CMD或powershell作为管理员和类型。
set PATH=%PATH%;C:\Python27
#4
2
Make sure you don't put a space between the semi-colon and the new folder location that you are adding to the path.
确保在分号和添加到路径的新文件夹位置之间不要放置空格。
For example it should look like...
例如,它应该看起来像……
{last path entry};C:\Python27;C:\Python27\Scripts;
去年路径条目} {;C:\ Python27;C:\ Python27 \脚本;
...not...
…不…
{last path entry}; C:\Python27; C:\Python27\Scripts;
{去年路径条目};C:\ Python27;C:\ Python27 \脚本;
#5
2
How to install Python / Pip on Windows Steps
如何在Windows步骤上安装Python / Pip ?
- Visit the official Python download page and grab the Windows installer for the latest version of Python 3. python.org/downloads/
- 访问官方的Python下载页面并获取最新版本的Python 3的Windows安装程序。python.org/downloads/
-
Run the installer. Be sure to check the option to add Python to your PATH while installing.
运行安装程序。在安装时,一定要检查在路径中添加Python的选项。
-
Open PowerShell as admin by right clicking on the PowerShell icon and selecting ‘Run as Admin’
打开PowerShell作为admin,右键单击PowerShell图标,选择“Run as admin”
-
To solve permission issues, run the following command:
要解决权限问题,运行以下命令:
Set-ExecutionPolicy Unrestricted
Set-ExecutionPolicy无限制的
-
Next, set the system’s PATH variable to include directories that include Python components and packages we’ll add later. To do this: C:\Python35-32;C:\Python35-32\Lib\site-packages\;C:\Python35-32\Scripts\
接下来,将系统的PATH变量设置为包含Python组件和我们稍后将添加的包的目录。要做到这一点:C:\ Python35-32;C:\ Python35-32 \ Lib \网站\;C:\ Python35-32 \ \的脚本
-
download the bootstrap scripts for easy_install and pip from https://bootstrap.pypa.io/ ez_setup.py get-pip.py
从https://bootstrap.pypa下载easy_install和pip的引导脚本。io / ez_setup。py get-pip.py
-
Save both the files in Python Installed folder Go to Python folder and run following: Python ez_setup.py Python get-pip.py
将Python安装文件夹中的文件都保存到Python文件夹,并运行如下:Python ez_setup。py Python get-pip.py
-
To create a Virtual Environment, use the following commands:
要创建虚拟环境,请使用以下命令:
cd c:\python pip install virtualenv virtualenv test .\test\Scripts\activate.ps1 pip install IPython ipython3 Now You can install any Python package with pip
cd c:\python pip安装virtualenv virtualenv测试。\测试\脚本\激活。ps1 pip安装IPython ipython3,现在您可以使用pip安装任何Python包。
That’s it !! happy coding Visit This link for Easy steps of Installation python and pip in windows http://rajendralora.com/?p=183
就是这样! !愉快的代码访问这个链接,方便安装python和pip在windows http://rajendralora.com/?p=183。
#6
2
Type this in Windows PowerShell
or CMD
:
输入Windows PowerShell或CMD:
"[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27", "User")"
After running the command, please restart PowerShell
or CMD
. If it still doesn't work, restart your PC.
运行该命令后,请重新启动PowerShell或CMD。如果它仍然不工作,重启你的电脑。
#7
1
i'm using python 2.7 in win 8 too but no problem with that. maybe you need to reastart your computer like wclear said, or you can run python command line program that included in python installation folder, i think below IDLE program. hope it help.
我在win 8中也使用了python 2.7,但是没有问题。也许您需要重新启动您的计算机,如wclear所说,或者您可以运行包含在python安装文件夹中的python命令行程序,我认为是在空闲程序下。希望它帮助。
#8
1
there is a simple procedure to do it go to controlpanel->system and security ->system->advanced system settings->advanced->environment variables
then add new path enter this in your variable path and values
有一个简单的程序去控制面板->系统和安全->系统->高级系统设置->高级->环境变量然后添加新的路径进入你的变量路径和值。
#9
1
Python doesn’t come prepackaged with Windows, but that doesn’t mean Windows users won’t find the flexible programming language useful. However with newer python (ie, 3.x) versions installation becomes very easy.But installing python 2.7 is little tricky.
Python并没有预装Windows,但这并不意味着Windows用户不会发现灵活的编程语言是有用的。然而,使用较新的python(即3.x)版本安装变得非常容易。但是安装python 2.7是很困难的。
Why Python 2.x ?
One of the main advantages of Python is the huge availability of third-party code for any imaginable task. That means that instead of writing everything from scratch, chances are that the most challenging bits of your application have already been written by someone else and made available to the community as a library, a module or a framework. But a language that doesn’t have this huge ecosystem available to you as a programmer is of little help, no matter how cool or sexy it looks. This is what is preventing so far a wider adoption of Python 3.x. Another reason is that many companies, from startups to giants such as Google, Quora or Dropbox, rely on millions of code lines written in Python 2.x. Upgrading their whole code base would be a huge challenge and very costly. Compatibility of huge libraries with python 2.x version makes it popular.
为什么Python 2。x ?Python的主要优点之一是可以为任何可想象的任务提供大量的第三方代码。这意味着,您的应用程序中最有挑战性的部分已经被其他人编写,并作为一个库、一个模块或一个框架提供给社区,而不是从头开始编写任何东西。但是,作为一个程序员,没有这个庞大的生态系统的语言是没有帮助的,不管它看起来多么酷或性感。这是迄今为止阻止更广泛采用Python 3.x的原因。另一个原因是,许多公司,从初创公司到像谷歌、Quora或Dropbox这样的巨头,都依赖于用Python 2.x编写的数以百万计的代码行。升级整个代码库将是一个巨大的挑战,而且代价非常高昂。大型库与python 2的兼容性。x版本让它很受欢迎。
1.Installing Python 2.7
1。安装Python 2.7
Download the package
下载包
=> https://www.python.org/download/releases/2.7/2.Adding Python to System Path.
3.Installing setuptools.
4.Installing PIP.
5.Adding PIP to path.
6.Installing Python Library using PIP.
Video Link => https://youtu.be/f3ZAidGFLSQ
#10
0
GUI Option:
GUI选择:
-
Open
System Properties
打开系统属性
a. Type it in the
Start Menu
a.在开始菜单中输入。
b. Use the keyboard shortcut Win+Pause)
b.使用快捷键Win+暂停键
c. From
Windows Explorer
address bar go to从Windows资源管理器地址栏到。
%windir%\System32\SystemPropertiesProtection.exe
% % \ System32系统\ SystemPropertiesProtection.exe列出
d. Write
SystemPropertiesProtection
in run window and press Enterd.在运行窗口中写入SystemPropertiesProtection,并按Enter。
-
Switch to the
Advanced
tab切换到Advanced选项卡。
- Click
Environment Variables
- 点击环境变量
- Select
PATH
in theSystem variables
section - 选择系统变量部分中的路径。
- Click
Edit
- 点击编辑
- Add python's path to the end of the list (the paths are separated by semicolons).
- 将python的路径添加到列表的末尾(路径用分号分隔)。
For example:
例如:
C:\Windows;C:\Windows\System32;C:\Python27
Command Line Option:
命令行选项:
- Run Command Prompt as administrator
- 作为管理员运行命令提示符。
-
Check existing paths under
PATH
variable (the paths are separated by semicolons). If your python folder already listed then no need to add again. Default python folder isC:\Python27
检查PATH变量下的现有路径(路径用分号分隔)。如果您的python文件夹已经列出,则无需再添加。默认的python文件夹是C:\Python27。
C:\Windows\system32>path
orC:\Windows\system32>echo %PATH%
C:\Windows\ system32系统>路径或C:\Windows\ system32系统>回声% %
-
Append python path using
setx
command. The/M
option sets the variable atSYSTEM
scope.使用setx命令添加python路径。M选项将变量设置为系统范围。
The default behavior is to set it for the USER
.
默认的行为是为用户设置它。
C:\Windows\system32>setx /M PATH "%PATH%;C:\Python27"
#1
60
I think that the essence of this question is how to install Python and be able to use it from the command line. The steps below show how to get all that working. Check that you didn't miss anything:
我认为这个问题的本质是如何安装Python并能够从命令行使用它。下面的步骤展示了如何实现所有这些工作。检查你没有错过任何东西:
- From https://www.python.org/download/releases/2.7.6 download appropriate Python 2.7.6 Windows Installer. (If that link doesn't work, check https://www.python.org/downloads/)
- 从https://www.python.org/download/releases/2.7.6下载适当的Python 2.7.6 Windows安装程序。(如果该链接不起作用,请检查https://www.python.org/downloads/)
- Run the file
- 运行该文件
- Select install for all users or install just for me, click Next
- 为所有用户选择安装或为我安装,单击Next。
- You'll see it installs under the C:\Python27 folder, click Next
- 您将看到它安装在C:\Python27文件夹下,单击Next。
- Click Next again for the 'Customize Python' step
- 再次单击“定制Python”步骤。
- Click Finish
- 单击Finish
- Open Control Panel, then System
- 打开控制面板,然后系统。
- Click 'Advanced system settings' on the left
- 点击左边的“高级系统设置”。
- Click the 'Environment Variables' button
- 点击“环境变量”按钮。
- Under 'System variables' click the variable called 'Path' then the 'Edit...' button. (This will set it for all users, you could instead choose to edit the User variables to just set python as a command prompt command for the current user)
- 在“系统变量”下点击“Path”变量,然后“编辑…””按钮。(这将为所有用户设置它,您可以选择编辑用户变量,将python设置为当前用户的命令提示命令)
- Without deleting any other text, add
C:\Python27;
(include the semi-colon) to the beginning of the 'Variable value' and click OK. - 不删除任何其他文本,添加C:\Python27;(包括分号)到“变量值”的开头,然后单击OK。
- Click OK on the 'Environment Variables' window.
- 在“环境变量”窗口中单击OK。
Open a new command prompt window type python
, you will have python running in the command prompt. Note: command prompt windows open prior to setting the Environment Variable will not have the python command available.
打开一个新的命令提示窗口类型python,您将在命令提示符中运行python。注意:在设置环境变量之前,命令提示窗口打开不会有python命令可用。
#2
5
System variables usually require a restart to become effective. Does it still not work after a restart?
系统变量通常需要重新启动才能生效。重启后还不工作吗?
#3
4
Easiest way is to open CMD or powershell as administrator and type
最简单的方法是打开CMD或powershell作为管理员和类型。
set PATH=%PATH%;C:\Python27
#4
2
Make sure you don't put a space between the semi-colon and the new folder location that you are adding to the path.
确保在分号和添加到路径的新文件夹位置之间不要放置空格。
For example it should look like...
例如,它应该看起来像……
{last path entry};C:\Python27;C:\Python27\Scripts;
去年路径条目} {;C:\ Python27;C:\ Python27 \脚本;
...not...
…不…
{last path entry}; C:\Python27; C:\Python27\Scripts;
{去年路径条目};C:\ Python27;C:\ Python27 \脚本;
#5
2
How to install Python / Pip on Windows Steps
如何在Windows步骤上安装Python / Pip ?
- Visit the official Python download page and grab the Windows installer for the latest version of Python 3. python.org/downloads/
- 访问官方的Python下载页面并获取最新版本的Python 3的Windows安装程序。python.org/downloads/
-
Run the installer. Be sure to check the option to add Python to your PATH while installing.
运行安装程序。在安装时,一定要检查在路径中添加Python的选项。
-
Open PowerShell as admin by right clicking on the PowerShell icon and selecting ‘Run as Admin’
打开PowerShell作为admin,右键单击PowerShell图标,选择“Run as admin”
-
To solve permission issues, run the following command:
要解决权限问题,运行以下命令:
Set-ExecutionPolicy Unrestricted
Set-ExecutionPolicy无限制的
-
Next, set the system’s PATH variable to include directories that include Python components and packages we’ll add later. To do this: C:\Python35-32;C:\Python35-32\Lib\site-packages\;C:\Python35-32\Scripts\
接下来,将系统的PATH变量设置为包含Python组件和我们稍后将添加的包的目录。要做到这一点:C:\ Python35-32;C:\ Python35-32 \ Lib \网站\;C:\ Python35-32 \ \的脚本
-
download the bootstrap scripts for easy_install and pip from https://bootstrap.pypa.io/ ez_setup.py get-pip.py
从https://bootstrap.pypa下载easy_install和pip的引导脚本。io / ez_setup。py get-pip.py
-
Save both the files in Python Installed folder Go to Python folder and run following: Python ez_setup.py Python get-pip.py
将Python安装文件夹中的文件都保存到Python文件夹,并运行如下:Python ez_setup。py Python get-pip.py
-
To create a Virtual Environment, use the following commands:
要创建虚拟环境,请使用以下命令:
cd c:\python pip install virtualenv virtualenv test .\test\Scripts\activate.ps1 pip install IPython ipython3 Now You can install any Python package with pip
cd c:\python pip安装virtualenv virtualenv测试。\测试\脚本\激活。ps1 pip安装IPython ipython3,现在您可以使用pip安装任何Python包。
That’s it !! happy coding Visit This link for Easy steps of Installation python and pip in windows http://rajendralora.com/?p=183
就是这样! !愉快的代码访问这个链接,方便安装python和pip在windows http://rajendralora.com/?p=183。
#6
2
Type this in Windows PowerShell
or CMD
:
输入Windows PowerShell或CMD:
"[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27", "User")"
After running the command, please restart PowerShell
or CMD
. If it still doesn't work, restart your PC.
运行该命令后,请重新启动PowerShell或CMD。如果它仍然不工作,重启你的电脑。
#7
1
i'm using python 2.7 in win 8 too but no problem with that. maybe you need to reastart your computer like wclear said, or you can run python command line program that included in python installation folder, i think below IDLE program. hope it help.
我在win 8中也使用了python 2.7,但是没有问题。也许您需要重新启动您的计算机,如wclear所说,或者您可以运行包含在python安装文件夹中的python命令行程序,我认为是在空闲程序下。希望它帮助。
#8
1
there is a simple procedure to do it go to controlpanel->system and security ->system->advanced system settings->advanced->environment variables
then add new path enter this in your variable path and values
有一个简单的程序去控制面板->系统和安全->系统->高级系统设置->高级->环境变量然后添加新的路径进入你的变量路径和值。
#9
1
Python doesn’t come prepackaged with Windows, but that doesn’t mean Windows users won’t find the flexible programming language useful. However with newer python (ie, 3.x) versions installation becomes very easy.But installing python 2.7 is little tricky.
Python并没有预装Windows,但这并不意味着Windows用户不会发现灵活的编程语言是有用的。然而,使用较新的python(即3.x)版本安装变得非常容易。但是安装python 2.7是很困难的。
Why Python 2.x ?
One of the main advantages of Python is the huge availability of third-party code for any imaginable task. That means that instead of writing everything from scratch, chances are that the most challenging bits of your application have already been written by someone else and made available to the community as a library, a module or a framework. But a language that doesn’t have this huge ecosystem available to you as a programmer is of little help, no matter how cool or sexy it looks. This is what is preventing so far a wider adoption of Python 3.x. Another reason is that many companies, from startups to giants such as Google, Quora or Dropbox, rely on millions of code lines written in Python 2.x. Upgrading their whole code base would be a huge challenge and very costly. Compatibility of huge libraries with python 2.x version makes it popular.
为什么Python 2。x ?Python的主要优点之一是可以为任何可想象的任务提供大量的第三方代码。这意味着,您的应用程序中最有挑战性的部分已经被其他人编写,并作为一个库、一个模块或一个框架提供给社区,而不是从头开始编写任何东西。但是,作为一个程序员,没有这个庞大的生态系统的语言是没有帮助的,不管它看起来多么酷或性感。这是迄今为止阻止更广泛采用Python 3.x的原因。另一个原因是,许多公司,从初创公司到像谷歌、Quora或Dropbox这样的巨头,都依赖于用Python 2.x编写的数以百万计的代码行。升级整个代码库将是一个巨大的挑战,而且代价非常高昂。大型库与python 2的兼容性。x版本让它很受欢迎。
1.Installing Python 2.7
1。安装Python 2.7
Download the package
下载包
=> https://www.python.org/download/releases/2.7/2.Adding Python to System Path.
3.Installing setuptools.
4.Installing PIP.
5.Adding PIP to path.
6.Installing Python Library using PIP.
Video Link => https://youtu.be/f3ZAidGFLSQ
#10
0
GUI Option:
GUI选择:
-
Open
System Properties
打开系统属性
a. Type it in the
Start Menu
a.在开始菜单中输入。
b. Use the keyboard shortcut Win+Pause)
b.使用快捷键Win+暂停键
c. From
Windows Explorer
address bar go to从Windows资源管理器地址栏到。
%windir%\System32\SystemPropertiesProtection.exe
% % \ System32系统\ SystemPropertiesProtection.exe列出
d. Write
SystemPropertiesProtection
in run window and press Enterd.在运行窗口中写入SystemPropertiesProtection,并按Enter。
-
Switch to the
Advanced
tab切换到Advanced选项卡。
- Click
Environment Variables
- 点击环境变量
- Select
PATH
in theSystem variables
section - 选择系统变量部分中的路径。
- Click
Edit
- 点击编辑
- Add python's path to the end of the list (the paths are separated by semicolons).
- 将python的路径添加到列表的末尾(路径用分号分隔)。
For example:
例如:
C:\Windows;C:\Windows\System32;C:\Python27
Command Line Option:
命令行选项:
- Run Command Prompt as administrator
- 作为管理员运行命令提示符。
-
Check existing paths under
PATH
variable (the paths are separated by semicolons). If your python folder already listed then no need to add again. Default python folder isC:\Python27
检查PATH变量下的现有路径(路径用分号分隔)。如果您的python文件夹已经列出,则无需再添加。默认的python文件夹是C:\Python27。
C:\Windows\system32>path
orC:\Windows\system32>echo %PATH%
C:\Windows\ system32系统>路径或C:\Windows\ system32系统>回声% %
-
Append python path using
setx
command. The/M
option sets the variable atSYSTEM
scope.使用setx命令添加python路径。M选项将变量设置为系统范围。
The default behavior is to set it for the USER
.
默认的行为是为用户设置它。
C:\Windows\system32>setx /M PATH "%PATH%;C:\Python27"