I have project where I have created multiple python files based on its usage. It works completely fine when I run from the pycharm. However, when I run the same from the terminal, I get the error: ModuleNotFoundError: No module named 'dataflow'
I need to make the dataflow out of this and need to deploy and it is giving an error while doing so.
Folder structure of the project, this works when I run from PyCharm
Error while running it from the terminal
Adducated guess, runs pychar your code in venv too? If not you might check if you installed the package that is missing in your venv.
Update
if you intent to have a dataflow package that you want to import and use the modules in it you need a __init__.py file in your dataflow folder. this makes it a package for python. If you want to use the modules in dataflow with the . in an import you need to do an import in __init__.py
like so
import .driver_main
this makes stuff from driver_main available in dataflow but better practice would be to specifiy what you want to access from driver_main like
from .driver_main import MyDriver
this will gibe you access to my driver via
dataflow.MyDriver
If you really just want to acces stuff from one module on the same lvl you should able to do so with the same approach. so in you exaple you showed in the picture try to change
from dataflow import driver_main
to
from . import driver_main
this would apply to an import in a module on the same lvl as driver_main.py like app.py
Update on Comments in original post
btw the env in pychar has nothing to do with the venv in the console. You simply telling pycharm to use python 3.7 but with your venv you copy binaries in a folder stucture. that said if you run an virtual environment all stuff you pip there gets copied in this folder structure not in the global site-packages. This means if you installed stuff global you wont have it right away in the virtual env and the other way around!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.