30 Jul 2022
python3 -m venv venv
(same command -
. is a shortcut for
Option 2 - with library
pip3 install virtualenv
Load automatically in VS Code
.vscode > settings.json add:
`rm -rf venv`
venv/bin/activate file can be opened to check the Python path. This is what matters:
VIRTUAL_ENV="/Users/path/to/project/folder/venv" export VIRTUAL_ENV
script using Python global instead of venv
Ran into the issue where the script was using the global Python instead of the venv's.
After activating my venv, the
which command showed that the path is correct, double-confirmed by checking the file path in the
However, when running the script, it uses the global python install:
(venv) n1c@MacN imapee % which python /Users/n1c/Python/imapee/venv/bin/python
running the script:
(venv) n1c@MacN imapee % /usr/bin/python3 /Users/n1c/Python/imapee/test.py
It appeared that the file
pyvenv.cfg was messing things up - not sure how that file was generated/included. Renaming it (or deleting it) solved the issue.
have you tried turning it off and on again?
15 Aug 2022
same problem as above resurfaced with another project and
pyvenv.cfg didn't help.
Deleting venv with
rm -rf venv and reinstalling solved the issue.