Adding a .env file to vscode so it finds our python module

First published:

Last Edited:

Number of edits:

When developing a Python module with VSCode we will face the challenge of importing it within the IDE itself. This problem does not exist on PyCharm, which takes care of setting a proper development environment for us.

In order to make our module discoverable, we must create a .env file at the root of our project and add the environment variables we need to it:

PYTHONPATH=/path/to/project

I am not sure how this is handled by VSCode (would it append it to the PYTHONPATH? Would it overwrite it?)

VSCode is so primitive that if you open the terminal there's a chance the following command gives an empty results:

echo $PYTHONPATH;

while the code may find your module without problems.


Backlinks

These are the other notes that link to this one.

Comment

Share your thoughts on this note. Comments are not public, they are messages sent directly to my inbox.
Aquiles Carattino
Aquiles Carattino
This note you are reading is part of my digital garden. Follow the links to learn more, and remember that these notes evolve over time. After all, this website is not a blog.
© 2024 Aquiles Carattino
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License
Privacy Policy