Linked Questions

1 vote
1 answer
131 views

My project structure: project main.py modules client.py server.py find_host_ip.py Traceback: File "C:\...\main.py", line 1, in <module> from modules ...
Mikhail Beliy's user avatar
2 votes
0 answers
191 views

I already took a look at this solution Importing classes from different files in a subdirectory , however it's still not working for me. I have my __init__.py file where I make the import: from api....
CodeTrooper's user avatar
  • 1,880
0 votes
1 answer
122 views

So hello again. I noticed I have not been asking the best python questions, but pray, bear with me. I have been working with classes to adopt the OOP method, even though I like it not. So now I am ...
Bored Comedy's user avatar
0 votes
2 answers
117 views

How to import another class into python? I just started learning python and I don't understand importing. there are two files in one folder. How to import?
TKDzsola's user avatar
857 votes
24 answers
683k views

I'm trying to follow PEP 328, with the following directory structure: pkg/ __init__.py components/ core.py __init__.py tests/ core_test.py __init__.py In core_test.py I have the ...
skytreader's user avatar
  • 11.8k
806 votes
22 answers
952k views

How do I import a Python module given its relative path? For example, if dirFoo contains Foo.py and dirBar, and dirBar contains Bar.py, how do I import Bar.py into Foo.py? Here's a visual ...
Jude Allred's user avatar
  • 11.1k
678 votes
13 answers
857k views

I have a file called tester.py, located on /project. /project has a subdirectory called lib, with a file called BoxTime.py: /project/tester.py /project/lib/BoxTime.py I want to import BoxTime from ...
Adam Matan's user avatar
  • 138k
243 votes
9 answers
693k views

How can I import variables from one file to another? example: file1 has the variables x1 and x2 how to pass them to file2? How can I import all of the variables from one to another?
Some kid's user avatar
  • 2,577
112 votes
10 answers
291k views

I can't seem to get Python to import a module in a subfolder. I get the error when I try to create an instance of the class from the imported module, but the import itself succeeds. Here is my ...
ryeguy's user avatar
  • 67.3k
205 votes
1 answer
641k views

Before you mark it as duplicate please read my problem: I am trying to import a class from a file from a subdirectory > main.py > --->folder/ > ----->file.py and in file.py i have a ...
kemis's user avatar
  • 4,702
24 votes
4 answers
87k views

Here's the structure I'm working with: directory/ script.py subdir/ __init__.py myclass01.py myclass02.py What I want to do is ...
liewl's user avatar
  • 4,061
13 votes
5 answers
13k views

I'm new to Python and i have looked around on how to import my custom modules from a directory/ sub directories. Such as this and this. This is my structure, index.py __init__.py modules/ hello.py ...
Run's user avatar
  • 57.7k
11 votes
2 answers
20k views

I'm using Python 3.6 on Windows 10. I have 2 .py files in the same directory, char.py, and char_user.py, as follows: char.py: # char.py import cv2 #################################################...
cdahms's user avatar
  • 3,840
7 votes
1 answer
8k views

I've got a python3 script, script.py, and in it I want to instantiate a class Foobar which is defined in clazz.py. However, when I try to import, I get: $ python3 script.py ... SystemError: Parent ...
tytk's user avatar
  • 2,402
3 votes
2 answers
8k views

This is my folder structure: storage/ __init__.py - contains class StorageAbstract, class DummyStorage, class STORE_TYPE file.py - contains class FileStorage db/ __init__.py - ...
Jan Pisl's user avatar
  • 1,223

15 30 50 per page