繁体   English   中英

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

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

每当我尝试在 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:\;]

以下是您可以尝试的事情:

1)保存文件(确保文件名后添加.py扩展名)

在 windows 上:

i)在搜索栏中搜索Python

ii)右键单击,然后单击打开文件位置

iii)您将在一个文件夹中看到 3 个或更多快捷方式。 右键单击其中任何一个,然后单击打开文件位置。

iv) 然后,复制目录的位置。

v) 右键单击“这台电脑”。 Select 属性。

vi) 在右侧,单击高级系统设置。

vii) 将出现一个弹出窗口。 在高级选项卡中,单击环境变量。

viii)从系统变量中,单击“路径”,然后单击“编辑”。

ix) 单击“新建”,然后将复制的目录粘贴到那里。 点击“确定”

x) 关闭 Sublime 并重新打开它。

它应该可以正常工作。

暂无
暂无

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

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