Python Forum

Full Version: I can't import own package of file from file.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
 
myapp
  | subdir
  |   |  myfile.py
  |   |
  | sample.py


# myfile.py
from .. import subdir # giving relative import error!
I don't want add directorty to sys.path. I saw at in another wepsite the users can import own package but my python interpreter do not allow this.
Quote:
# giving relative import error!


What is the full verbatim of the traceback?
SystemError: Parent module '' not loaded, cannot perform relative import
please help me.
Which are you running?

myfile.py won't work, since it's not part of a package.
myapp might work, as long as there's a python file you're running.

Importing the folder also doesn't really make sense, unless there's an __init__.py file inside it.

So really, in order for us to help, we need to know:
1) what files are in which folders
2) which file you're actually trying to run