My operation system is macOs Ventura
This problem happens as i think only with VSC, becuase opening same folder via PyCharm all is importing successfully.
[Screenshot of Error,pipenv --venv
, pipenv --wheree
and pipenv --graph
]:(https://i.stack.imgur.com/PR3Vh.png
I have created directory (folder), created local virtual environment via pipenv install django
and active its via pipenv shell
. Imports working good … but just in PyCharm.
I have tried to reinstall VSC — not helped.
I have assumed that in sys.path
wasn’t written this path /Users/sheenaz/.local/share/virtualenvs/Polls-njzI0GZr/lib/python3.11/site-packages
— it was.
I have tried to reinstall pipenv and django — not helped.
As you can see that interpretator has entered correctly, but still doesn’t work (modules not importing).
I want that my modules will able to importing, can sombedy help?
I know answer!
At first it’s a problem not with VSC or pipenv, It’s just a problem with Code Runner extension that I use.
So, by deafault Code Runner python executor map is python
or python3
, you need substitute this by your virual environment executor or inerpreter.
To fix this go to the settings.json or to VSC code and in settings search type Code-runner: Executor Map
. Now you in settings.json either or again).
Search for key "code-runner.executorMap"
in dict and as you have finded then search key "python"
and by default you will get defeault value like "python"
or "python3"
maybe. You need to change this value to your python virtual environment executor map (interpreter).
In my instance it is the pipenv interpreter — /Users/sheenaz/.local/share/virtualenvs/PLPY-ELrCBZFZ/bin/python3
2
Answers
Install specific debugger in VSCode. In my situation, debugger for OpevCV:
Because in Pycharm you install package with everything needed, while in VSC you need to additionally install the debugger.
Same problem on MacOS Ventura, had no problem running the same environment on MacOS Monterey, where imports work. Here assumed it’s a path issue, after solving dependencies
export PYTHONPATH=/path/to/dir:$PYTHONPATH
then activate imports, by specifying both interpreter and path in VSCode (I have anaconda on Ventura and Python through Brew on the Monterey setup). Both now work.