Python 3.6无法通过命令提示符运行

时间:2017-12-10 23:17:28

标签: python windows python-3.x windows-10

问题:

我在两者中都包含了Python的安装路径(C:\ Program Files \ Python36) “Path”和“PYTHONPATH”系统变量。我暂时不需要使用Python,我确信它上次工作(接近几个月前)。 Python IDLE仍然有效,但我需要通过命令提示符使用Python。

我在网上找到的其他类似问题通常都是通过对系统变量进行适当的更改来解决的。

尝试执行任何与Python相关的任务时出现错误消息: python : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + python + ~~~~~~ + CategoryInfo : ObjectNotFound: (python:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

到目前为止我做了什么:

  • 通过控制面板将系统变量设置为Python路径>系统和安全性>系统>高级系统设置>环境变量
  • 尝试使用cd直接从其安装位置使用python

2 个答案:

答案 0 :(得分:-1)

您是否更改了命令提示符的目录? 如果您尝试打开shell,请尝试执行以下操作:

cd C:\Program Files\Python36
输入

之前输入

python 

启动shell。

我的Java编译出现了类似的问题,出于某种原因,设置环境变量不会削减它。 如果您正在尝试运行预先编写的程序,请尝试:

set path="C:\Program Files\Python36"

等效目录适用于Java。然后使用以下命令将自己定位到文件的位置:

cd C:\location

我希望这就是你想要的。 ☺️

答案 1 :(得分:-1)

解决方案:

Python的安装路径被Visual Studio覆盖了它的共享"位置(更像是痛苦的位置)位于: IncomingPhoneNumberInstance {#249 ▼ #_assignedAddOns: null #version: V2010 {#244 ▶} #context: null #properties: array:30 [▼ "accountSid" => "**" "addressSid" => null "addressRequirements" => "none" "apiVersion" => "2010-04-01" "beta" => false "capabilities" => array:4 [▶] "dateCreated" => DateTime {#250 ▶} "dateUpdated" => DateTime {#251 ▶} "friendlyName" => "(218) 963-5608" "identitySid" => null "phoneNumber" => "+12189635608" "origin" => "twilio" "sid" => "**" "smsApplicationSid" => "" "smsFallbackMethod" => "POST" "smsFallbackUrl" => "" "smsMethod" => "POST" "smsUrl" => "" "statusCallback" => "" "statusCallbackMethod" => "POST" "trunkSid" => null "uri" => "/2010-04-01/Accounts/ACcc7e0c85b66b0414485f08a1e03abdba/IncomingPhoneNumbers/PNe2bd51168e719b86cee6c9c46074e46c.json" "voiceApplicationSid" => null "voiceCallerIdLookup" => false "voiceFallbackMethod" => "POST" "voiceFallbackUrl" => null "voiceMethod" => "POST" "voiceUrl" => "http://example.app" "emergencyStatus" => "Inactive" "emergencyAddressSid" => null ]

将系统变量(C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\ Path )更改为此位置可解决此问题。

感谢所有评论/回复的人。

编辑:显然手动设置PYTHONPATH是不好的做法,因为它是由Python自动设置的。

相关问题