简体   繁体   中英

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:

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)

On windows:

i)Search Python in the search bar

ii)Right Click and then click on Open file Location

iii)You will see 3 or more shortcuts in a folder. Right click on anyone of them and then click on Open file location.

iv) Then, copy the location of the directory.

v)Right Click on 'This PC'. Select Properties.

vi) On the right hand side, click on Advanced system settings.

vii) A pop up will appear. From the Advanced tab, click on Environmental Variables.

viii)From System Variables, Click on 'Path' and click 'Edit'.

ix) CLick 'New' and then paste the copied directory there. Click 'OK'

x) Close Sublime and Reopen it.

It should work fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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