#๐Ÿ”’ Activate a Virtual Env when I'm in a folder

25 messages ยท Page 1 of 1 (latest)

worthy mountain
#

Is there a way to automatically activate a venv when I'm in a certain folder? I'm using terminal mostly on Linux wsl.

typing source blah/blah seems tedious and I'm sure there's a better way

old oracleBOT
#

@worthy mountain

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

worthy mountain
#

My Py virtual environment is just created using python -m venv blahblah, if that matters.

grizzled creek
#

there are lots of tools for this

#

they all involve tweaking your shell's cd function

worthy mountain
#

Is ther a 'meta' way to do it?

#

Or are people working in python generally just activating their venv each time

grizzled creek
worthy mountain
#

ah it's ok, i think ill just do it manually rather than go down a less trodden path

grizzled creek
#

I tend to spend hours at a time working in a given virtualenv, so it's not a burden for me to activate it "manually"

worthy mountain
#

that's fine! thanks for the tips.

#

I'll just learn to activate it manually ๐Ÿ˜„

astral latch
#

what OS are you on?

grizzled creek
worthy mountain
#

W11, but using WSL into Ubuntu

grizzled creek
#

My laptop is MacOS; my code runs (in docker) on Debian

worthy mountain
#

Annoyingly I also have a similar workflow on MacOS ๐Ÿ˜‚

astral latch
opaque wind
#

There are also tools that don't activate a venv when you cd (you don't modify the cd), but rather have activate command that automatically cd to the project ๐Ÿ˜„

I've used virtualenvwrapper in the past. It generally stored venvs in a single central location instead of inside project folder... But had an option to link a path of the project to cd automatically or via a command.

astral latch
#

pyenv has something that actually does this.

grizzled creek
#

and then of course there's poetry shell or uv shell

old oracleBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.