I have a directory structure like this:
my_project
.idea
src
config.ini
method.py
... other py modules
When I open the project in PyCharm and run with the configuration below, it runs perfectly. It runs src.method
as a module using an Anaconda 3 environment. The src.method
module uses relative imports from other modules in src
and takes config.ini
as an argument.
I am trying to run the module in the same way through the Windows command line from src
as the working directory
C:\Users\deimos\Anaconda3\envs\cveureka\python.exe -m src.method "config.ini"
but this gives a ModuleNotFoundError
saying it could not find src
. I tried replacing src.method
with just method
but that gives ImportError: attempted relative import with no known parent package
.
I have also tried setting the PYTHONPATH
before running the module with
setlocal
set PYTHONPATH=%2
like in this answer, but to no effect.
It there a way to set up the command line to replicate the way that PyCharm runs the module?