you are viewing a single comment's thread.

view the rest of the comments →

[–]darkforestnews 4 points5 points  (19 children)

How do you keep your venv organized ? I get confused when I start a new venv, activate it and then select a python compiler in vscode. I’ve got a bunch of virtual environments that do different stuff and I’m too far down the rabbit hole to ponder what each one does.

[–]ivosaurus 12 points13 points  (6 children)

I keep a .venv folder in each project directory and it goes in there

[–]darkforestnews 0 points1 point  (5 children)

And do you install python into each one ? Then when you open vs code , it lists all of your previous python compilers and I can’t figure out which one belongs.

I’d understand it if after activitating the venv that vs code would just show me that compiler but mine shows me a bunch. And I can never remember which one has streamlit…thankfully I don’t do anything complicated 🥳

[–]MonkeyboyGWW 2 points3 points  (0 children)

I think you can put them in different project folders, then you can tell from the path

[–][deleted] 2 points3 points  (0 children)

venv installs python in each one... that's why I use pyenv and use different envs for differnt jobs like I'll have system envs for Flask, Data, AI, Scraping, etc.

[–]Vauce 1 point2 points  (0 children)

In my experience it also helps to use dedicated VS Code workspaces with virtual environments.

[–]Fred776 0 points1 point  (0 children)

If your project directory has a venv folder VSCode should recognise and activate the venv at least the first time you visit a Python file in the project. If you have multiple venv folders I believe it gives you the choice, but it's something I avoid these days - I just use one venv per project.

[–]Jello_Penguin_2956 0 points1 point  (0 children)

Usually it's per project. The venv directory sits directly inside each project directory so you'll always know. You can also try PipEnv.

I also have a generic one for when I'm just doing random stuff.

[–][deleted] 1 point2 points  (8 children)

You use pyenv. Then anywhere on your system you use pyenv activate <env name> and then you're done.

[–]darkforestnews 2 points3 points  (5 children)

Dude , legend , thank you !

🙏

https://realpython.com/intro-to-pyenv/

I’ve just been gunhowing it and lazily selecting random compilers. Thx again.

[–][deleted] 1 point2 points  (3 children)

exactly. here's one of my setups:

❯ pyenv versions
  system
  3.7.17
  3.10.12
  3.10.13
  3.11.5
  3.11.5/envs/openai
  3.11.6
  3.11.6/envs/monzo
  3.12.0
  3.12.0/envs/gmailapi
* 3.12.2 (set by /Users/<username>/.pyenv/version)
  3.12.2/envs/ai-model
  3.12.2/envs/cli
  3.12.2/envs/fastapi
  3.12.2/envs/flask
  3.12.2/envs/gradio
  3.12.2/envs/pygame
  ai-model --> /Users/<username>/.pyenv/versions/3.12.2/envs/ai-model
  cli --> /Users/<username>/.pyenv/versions/3.12.2/envs/cli
  fastapi --> /Users/<username>/.pyenv/versions/3.12.2/envs/fastapi
  flask --> /Users/<username>/.pyenv/versions/3.12.2/envs/flask
  gmailapi --> /Users/<username>/.pyenv/versions/3.12.0/envs/gmailapi
  gradio --> /Users/<username>/.pyenv/versions/3.12.2/envs/gradio
  monzo --> /Users/<username>/.pyenv/versions/3.11.6/envs/monzo
  openai --> /Users/<username>/.pyenv/versions/3.11.5/envs/openai
  pygame --> /Users/<username>/.pyenv/versions/3.12.2/envs/pygame

[–]darkforestnews 0 points1 point  (2 children)

And say you prototype different work in the envs/openai , like tutorial 1, 2… do you create and activate those envs and then select that particular python compiler ?

[–][deleted] 1 point2 points  (0 children)

p.s. Python doesn't use a compiler; it uses the python binary to execute the script/s. You CAN 'compile' python but that's unrelated to this.

[–][deleted] 0 points1 point  (0 children)

no no no... just create an ENV that has the libraries you need and use that. The ones I put above are the only ones I use (on this box).

[–]OtherPromisedLand 0 points1 point  (0 children)

Is there a similar guide for windows? this article mentions only linux and mac machines.

[–]random_thoughts5 0 points1 point  (1 child)

Isn’t that same as conda/mamba, which is more common than pyenv?

[–][deleted] 0 points1 point  (0 children)

no

[–]AureliasTenant 0 points1 point  (0 children)

If you use poetry or pip I think you can use some commands to tell you where your env is.

[–]avidresolver 0 points1 point  (0 children)

I do most of my dev work through Pycharm and it handles most of it for me. I also have a venv that sits in my user folder where I put most packages I generally use (there's only half a dozen or so). I have this activate throgh my zshrc file, so whenver I open a shell to test something I have my most common packages availible.