Python Forum
I can't import own package of file from file.
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.
Reply
#2
Quote:
# giving relative import error!


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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Import XML file directly into Excel spreadsheet demdej 0 200 Jan-24-2023, 02:48 PM
Last Post: demdej
Thumbs Up Need to compare the Excel file name with a directory text file. veeran1991 1 195 Dec-15-2022, 04:32 PM
Last Post: Larz60+
Photo Making Zip file of a file and Directory Nasir 2 325 Oct-07-2022, 02:01 PM
Last Post: Nasir
  Need Help: Convert .pcl file to .pdf file ManuRaval 6 726 Sep-13-2022, 01:31 PM
Last Post: ManuRaval
  filter every 24 days file (considering file name) RolanRoll 5 1,140 Jun-23-2022, 11:41 AM
Last Post: RolanRoll
  Modify values in XML file by data from text file (without parsing) Paqqno 2 700 Apr-13-2022, 06:02 AM
Last Post: Paqqno
  How to split file by same values from column from imported CSV file? Paqqno 5 1,225 Mar-24-2022, 05:25 PM
Last Post: Paqqno
  Converted Pipe Delimited text file to CSV file atomxkai 4 3,487 Feb-11-2022, 12:38 AM
Last Post: atomxkai
  Reading Excel file and use a wildcard in file name and sheet name randolphoralph 6 2,856 Jan-13-2022, 10:20 PM
Last Post: randolphoralph
  How from sklearn.datasets import load_diabetes change to import to CSV file Anldra12 0 951 Dec-25-2021, 07:20 PM
Last Post: Anldra12

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020