I'm trying to set pythonpath but when I follow in some example in other stackoverflow, I just get a red message or nothing happened.
In my picture, u can see, no my folder D:\DemoPython
Does anyone have exactly how to set it?, please give me some examples or the exact answer would be better. Thank so much.
2 Answers 2
The syntax for setting environment variables you found is for cmd.exe (the DOS-like prompt that has shipped with Windows for ages). You're running in PowerShell, which is newer, and has significantly different syntax.
On PowerShell (which you're using), you want:
$env:PYTHONPATH = "D:\DemoPath;${env:PYTHONPATH}"
or
$env:PYTHONPATH = "${env:PYTHONPATH};D:\DemoPath"
depending on whether you want to take precedence over existing entries or not, respectively.
Comments
My Computer > Properties > Advanced System Settings > Environment Variables >
Just add the path as :
C:\Users\zee\AppData\Local\Programs\Python\Python39 (or wherever you installed python)
1 Comment
PYTHONPATH persistently is usually a bad idea (if you want something installed persistently, make it actually installable with setup.py/setup.cfg or the like and install it; you won't need customized environment variables); the code it references must work (or at least be syntactically valid) in all versions of Python that imports it, which can be a problem (it's a huge problem when you're still mixing Py 2 and Py 3).
cmd.exe(DOS-like) prompt, but using PowerShell. You need to match the syntax to the shell.