Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 I can't import own package of file from file.
#1
 
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
#2
Quote:
# giving relative import error!


What is the full verbatim of the traceback?
Quote
#3
SystemError: Parent module '' not loaded, cannot perform relative import
Quote
#4
please help me.
Quote
#5
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
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Call a python file with anothr python file skaailet 3 175 Apr-30-2020, 03:41 PM
Last Post: deanhystad
  Code import .CSV file to MySQL table rtakle 4 199 Apr-30-2020, 03:16 PM
Last Post: anbu23
  import scalalib package doesn't work manu_brighter 2 198 Apr-17-2020, 06:36 PM
Last Post: snippsat
  Importing module from a package results in import error goghvv 2 225 Mar-27-2020, 07:13 PM
Last Post: goghvv
  can we write command output to new csv file using Panda package? PythonBeginner_2020 3 330 Mar-13-2020, 12:38 PM
Last Post: ndc85430
  make a list of the file in the folder and change the name of file regarding to time go127a 5 362 Feb-21-2020, 10:36 AM
Last Post: go127a
  Python: possibilty ro make a list of the file in the folder & change the name of file go127a 0 170 Feb-05-2020, 01:16 PM
Last Post: go127a
  Import all items from all modules from package DD169 3 258 Jan-25-2020, 12:33 PM
Last Post: buran
  Regarding import library in two different program file Rohit 3 276 Jan-22-2020, 07:14 AM
Last Post: buran
  Rename file from value in text file Nuge93 1 257 Jan-20-2020, 03:50 PM
Last Post: gruntfutuk

Forum Jump:


Users browsing this thread: 1 Guest(s)