2

I'm using Python 3.6

my file structure:

ACS-backend
    ACS
        -__init__.py
        -main.py
        -VCDN.py
    bin
    data
    docs
    venv
    weights
    -.gitignore
    -requirements.txt
    -setup.py

I'm trying to import VCDNN in my main.py with from ACS.VCDNN import VCDNN I have tried with just .VCDNN from VCDNN and just VCDNN from VCDNN the last one used to work before ive added the ACS folder.

To run it from cmd i simply do venv/Scripts/activate.bat to activate my current VENV and then just python main.py and the error I get is:

Traceback (most recent call last):
  File "main.py", line 5, in <module>
    from ACS.VCDNN import VCDNN
ModuleNotFoundError: No module named 'ACS'

Though when running from PyCharm i see that it executes:

C:\work\COMP1682\ACS-backend\venv\Scripts\python.exe C:/work/COMP1682/ACS-backend/ACS/main.py

which works fine, but when I run the exact same command from my CMD it still gives me the same error.

Higeath
  • 101
  • 1
  • 10
  • Try running as `python -m ACS` See more details here : https://stackoverflow.com/questions/22241420/execution-of-python-code-with-m-option-or-not – user238607 Nov 18 '18 at 12:39
  • @user238607 'ACS' is a package and cannot be directly executed tried also python -m ACS.main.py no luck – Higeath Nov 18 '18 at 12:55
  • remove the ending .py. Use "python -m ACS.main" – user238607 Nov 18 '18 at 12:57
  • @user238607 that seems to be passing but now it's complaining about me accessing a file from data directory (outside of ACS) by doing ../data/file.csv – Higeath Nov 18 '18 at 13:03
  • Since your working directory is the same as the one which contains both ACS and data directory. You need to remove the initial ".." from the location. Use `data/file.csv` – user238607 Nov 18 '18 at 13:05

1 Answers1

2

Try from .VCDN import VCDNN, that would be correct relative import.