0

I have a package I created in the root/Drivers/OTP folder called totp.py.

When I import the package with import Drivers.OTP.totp as totp, PyCharm automatically suggests the correct folder, package, and module. PyCharm also auto suggests the functions from that package import.

However, when I run the module that imports that module, python itself errors out with:

ModuleNotFoundError: No module named 'Drivers'

The calling module is located at root/ApiAdapters/Passwordstate/secrets.py.

What gives?

Dshiz
  • 3,099
  • 3
  • 26
  • 53
  • How, exactly, are you running the code? Are you running it inside of PyCharm, or at the command line, or some other way? – John Gordon Dec 08 '22 at 20:29
  • Command line.. I will try with PyCharm – Dshiz Dec 08 '22 at 20:31
  • It works fine when running it with PyCharm.. Shouldn't both work the same way? – Dshiz Dec 08 '22 at 20:33
  • Mark the root as sources path, you can also [make an installable package](https://stackoverflow.com/questions/62498127) in which case activating the venv is enough after installing the package. – bad_coder Dec 08 '22 at 21:39

1 Answers1

0

try importing from root. So import root.Drivers......

Ed Vraz
  • 52
  • 2