简体   繁体   English

无法在 sublime text 3 中运行 python 代码

[英]Not able to run python code in sublime text 3

Whenever I tried to run my python code in sublime text 3 it shows the error of long paragraph like this:每当我尝试在 sublime text 3 中运行我的 python 代码时,它都会显示长段的错误,如下所示:

Traceback (most recent call last):
  File "C:\Users\Abhishek Kumar\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Abhishek Kumar\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\Abhishek Kumar\AppData\Local\Programs\Python\Python38-32\lib\py_compile.py", line 218, in <module>
    sys.exit(main())
  File "C:\Users\Abhishek Kumar\AppData\Local\Programs\Python\Python38-32\lib\py_compile.py", line 209, in main
    compile(filename, doraise=True)
  File "C:\Users\Abhishek Kumar\AppData\Local\Programs\Python\Python38-32\lib\py_compile.py", line 157, in compile
    os.makedirs(dirname)
  File "C:\Users\Abhishek Kumar\AppData\Local\Programs\Python\Python38-32\lib\os.py", line 221, in makedirs
    mkdir(name, mode)
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\Users\\Abhishek Kumar\\Documents\\html\\__pycache__'
[Finished in 0.2s with exit code 1]
[shell_cmd: python -m py_compile "C:\Users\Abhishek Kumar\Documents\html\hello.py"]
[dir: C:\Users\Abhishek Kumar\Documents\html]
[path: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Users\Abhishek Kumar\AppData\Local\Microsoft\WindowsApps;C:\Python27;C:\Users\Abhishek Kumar\AppData\Local\Microsoft\WindowsApps;C:\Users\Abhishek Kumar\AppData\Local\Programs\Python\Python38-32;C:\Users\Abhishek Kumar\AppData\Local\Programs\Python\Python38-32\Scripts;C:\Users\Abhishek Kumar\AppData\Local\Sublime Text 3\Cache;C:\;]

Here are things that you can try:以下是您可以尝试的事情:

1) Save the file (makes sure to add.py extension after file name) 1)保存文件(确保文件名后添加.py扩展名)

On windows:在 windows 上:

i)Search Python in the search bar i)在搜索栏中搜索Python

ii)Right Click and then click on Open file Location ii)右键单击,然后单击打开文件位置

iii)You will see 3 or more shortcuts in a folder. iii)您将在一个文件夹中看到 3 个或更多快捷方式。 Right click on anyone of them and then click on Open file location.右键单击其中任何一个,然后单击打开文件位置。

iv) Then, copy the location of the directory. iv) 然后,复制目录的位置。

v)Right Click on 'This PC'. v) 右键单击“这台电脑”。 Select Properties. Select 属性。

vi) On the right hand side, click on Advanced system settings. vi) 在右侧,单击高级系统设置。

vii) A pop up will appear. vii) 将出现一个弹出窗口。 From the Advanced tab, click on Environmental Variables.在高级选项卡中,单击环境变量。

viii)From System Variables, Click on 'Path' and click 'Edit'. viii)从系统变量中,单击“路径”,然后单击“编辑”。

ix) CLick 'New' and then paste the copied directory there. ix) 单击“新建”,然后将复制的目录粘贴到那里。 Click 'OK'点击“确定”

x) Close Sublime and Reopen it. x) 关闭 Sublime 并重新打开它。

It should work fine.它应该可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM