Python Forum

Full Version: Import Python Modules
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am working to make a pyhton web framework, I make a package and installed that, and the main directory is in
venv/lib/python3.6/site-packages/main-folder ,
In the directort where venv is situated there I made a file and importing a module, that module is situated in the main-folder , but from parent directory i can't import that. I am working in virtual environment. Is there any way that I can easily import that needed stuff even though I am not in same directory as main-folder.
I want to import just like, import time
how to make my module so that it can be easily imported without copying directory to current path.?
You should be able to do
from main-folder import <file to import>

or if the name of the file is "__init__"
import main-folder
error: no module named file.py
is "file.py" the name of your file
and can I see the code

If the file is in a folder and u are using the from method. You may have to add a __init__ file to the folder so it is recognized as a package. The __init__ file can empty
zowhair Wrote:error: no module named file.py
Please post the whole exception traceback that python writes in your console.