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
  How to extract a matrix from .xml.gz file to a excel file or any other output? enyrb 0 54 Oct-21-2019, 01:01 PM
Last Post: enyrb
  Does python guarantees that file.write() works without file.close() ? kryptomatrix 7 194 Oct-21-2019, 11:28 AM
Last Post: kryptomatrix
  Writing list as a file, then reading that file as a list Zoastria_Balnala 3 108 Oct-17-2019, 07:54 PM
Last Post: Zoastria_Balnala
  How to import the name of the fluid in CoolProp from an yml file termo 0 59 Sep-26-2019, 01:32 PM
Last Post: termo
  python file output to log file Rsh 4 306 Aug-13-2019, 09:00 PM
Last Post: DeaD_EyE
  How to fetch file from a list which match file extension suddhasilsarkar 1 150 Jul-30-2019, 11:54 AM
Last Post: Malt
  How do you import a dictionary from a .csv file? SteampunkMaverick12 2 226 Jul-29-2019, 09:20 AM
Last Post: sudheerm
  Trying to make column based file from text file scor1pion 7 282 Jul-16-2019, 02:43 PM
Last Post: scor1pion
  I need help! How to package python code with other component into an exe file?? Wendy 4 271 Jul-15-2019, 01:29 PM
Last Post: snippsat
  looking for sample py to read from txt file into XML using lxml import etree venkat18 3 330 Jun-02-2019, 04:34 AM
Last Post: venkat18

Forum Jump:


Users browsing this thread: 1 Guest(s)