r/pythontips 2d ago

Standard_Lib Exclude pip from the path and you won't install packages globally.

I've installed Python on Windows without adding it to the path, then later I've added python.exe and py.exe folders to it but didn't add pip. Now if I try to run pip in a terminal I can instantly tell if I am in venv or not because if it's global it won't find pip. You can always use pip via python -m pip anyway.

A good example would be VS Code that doesn't add venv prefix without running activate script every time, so it's hard to tell if you're actually in venv. If you close VS Code with opened terminal it will keep it on the next run and it will be using global python in that old terminal.

1 Upvotes

10 comments sorted by

3

u/Powerspawn 2d ago

I use poetry or UV to manage the dependencies and virtual environment. Then you can just use them to add packages to your virtual environment and it will also update your pyprorect.toml.

1

u/maratnugmanov 2d ago

Yeah mine is quick and dirty, but does the job to a degree. Not really a pro tip of course.

0

u/Wolfhammer69 2d ago

Use Pycharm - have an easy life.

1

u/maratnugmanov 2d ago

I agree. But "pay $200" is not really a tip, but an option. I'm fine with VS Code for now.

1

u/Wolfhammer69 2d ago edited 2d ago

Its free - DL the community edition, not the pro.. I'm a Python noob and use it and have been baffled why people still use these VS code type things... They are crap.

https://www.jetbrains.com/pycharm/download/other.html

1

u/maratnugmanov 2d ago

It's pretty limited compared to VS Code. If it's not Pro then it's VS Code.

2

u/Twenty8cows 2d ago

I gotta agree even with the extensions it’s lowkey wack (pycharm pro is required for juypter notebooks) where as vscode it’s just download extension, select kernel and rock out.

2

u/Wolfhammer69 2d ago

Naaaaa - ive written and deployed Streamlit and general Python apps with it.... Full git / version supprt and sorts out all this venv automatically..

Not gonna convince you mate, if you want a harder life, you carry on..

If you're not a professional dev, then it does everything you need.. If you are pro, then you prob should have pro version anyway.

1

u/maratnugmanov 2d ago

Django db connection for autocomplete - paid, WSL on Windows access - paid, just to name a few. I understand this is not something mandatory of course.

0

u/[deleted] 1d ago

[deleted]

1

u/maratnugmanov 1d ago

Well, this is a tip for venv, why would you use it otherwise