I'm in the middle of transferring my work away from PyCharm and into VS Code to minimize the number of IDE's open at the same time. As I've been doing that, I've noticed that importing is markedly different:
My layout is as follows:
Projects
- PythonProjects
-- ThisProject
---- TheScriptIRunPath
----- MyScript.py
---- MyModuleToImport.py
-- OtherProject
- NotPythonProjects
In PyCharm, I would just enter from PythonProjects.ThisProject.MyModuleToImport import *
and the import would work without a hitch. However, none of the imports seem to work this way in VS Code. I started on pylint and tried all of the suggestions here, none of which did the trick.
My original PyCharm organization just used the root environment for everything, so I didn't really pay any attention to venvs or build __init__
files.
However, one step I've been taking is separating my Anaconda environments to limit their size for each project. While picking the corresponding environments is straightforward enough in VS Code, I'm going to have to import modules from different environments, and I suspect that this is going to complicate importing modules from distinct environments even further.
But, first things first, what's the most hassle-free way to get my (hopefully PyCharm-styled) relative imports to work in VS Code in the same environment? Also, what else do I need to keep in mind as I start importing modules from separate environments?
I'm using Python 3.8.