1

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.

enter image description here

enter image description here

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.

1
  • You're following a guide for the plain cmd.exe (DOS-like) prompt, but using PowerShell. You need to match the syntax to the shell. Commented Apr 27, 2022 at 18:11

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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

Setting 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).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.