簡體   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