DEV Community

Kamal Mustafa
Kamal Mustafa

Posted on • Updated on

Python virtualenv no activate

My workflow when starting new python project or experimenting with something:-

mkdir myproject
cd myproject
python -mvenv venv
venv/bin/pip install something
venv/bin/python
>>> import something
Enter fullscreen mode Exit fullscreen mode

Look, there's no need to do something like source venv/bin/activate to make use of your virtual environment.

Not using activate also good for documentation like in README as you don't have the two steps commands and people forgot to run the first step problem.

Have ever got into situation where you have to ask, "Have you run source venv/bin/activate?" You don't need to ask this question if you invoke the venv directly.

Of course this is just for quick experimentation. For a real project we're using poetry. And here's labzero our starter project for django.

Top comments (2)

Collapse
 
stokito profile image
Sergey Ponomarev

I'm new to Python and checked the activate script has also unset PYTHONHOME.
Otherwise it looks like nothing really useful is there

Collapse
 
k4ml profile image
Kamal Mustafa

You can look in this post on creating the venv yourself:-

dev.to/k4ml/python-diy-virtualenv-...