All Questions
17 questions
0
votes
0
answers
35
views
Directory issue: Module not Found
I'm trying to import two modules in a main.py file. The file structure is like this
|Common-Folder
|
|
|__Folder
| |___main.py
|
|
|__Tools(folder)
| |___models
| |___maze
inside main, I do
import ...
0
votes
1
answer
614
views
How to import dependencies from other folder?
I have to folders A and B. In folder A is my main.py. In folder B there are a few classes in different scripts: B1.py, B2.py, B3.py…
I want to import a class from B1.py. I got that to work with sys....
0
votes
2
answers
63
views
Python import from another folder
I made this structure as an example:
application
| main.py
├── folder
├── __init__.py
└── file.py
when I want to import something in main.py from file.py, I can simply do
from folder.file ...
0
votes
2
answers
606
views
Import functions from another directory
I am running a python script (app.py) where I have to use two functions from another script (src.py), located inside another directory. The structure is the following:
Dir:
Dir_1:
__init__....
1
vote
1
answer
143
views
Import multi-nested subfolders in python neatly
I have the following directory structure:
.
├── main.py
└── subfolder1
├── file1.py # def hello(): print("hello")
├── __init__.py
└── subfolder2
├── file2.py # def world(...
0
votes
1
answer
142
views
How to import a .py file on jupyter notebook using the directory
I want to import .py file on jupyter notebook using a directory. How can i import this file on jupyter.
file path - C:\Users\Documents\AFR\hunk.py
For eg i want to import all the functions from the ...
0
votes
1
answer
28
views
Python 3.x: import a function, config dictionary, ... etc. from a file in a different directory
The folder tree of my project is:
project:
|
| -- src:
|--- dir_a:
|--- file_a.py
|--- dir_b:
|--- file_b.py
I want to import a function, config dictionary, ......
0
votes
1
answer
22
views
Accessing other files in various locations inside a given file?
I have the following folder structure (this was given to me and is expected to remain, so I cannot reorganize anything).
Folder1
Folder2.py
File1
Folder3
File2.py
...
0
votes
4
answers
423
views
Accessing code in adjacent files
I have code in one folder, and want to import code in an adjacent folder like this:
I am trying to import a python file in innerLayer2, into a file in innerLayer1
outerLayer:
innerLayer1
...
0
votes
0
answers
234
views
python: "sys.path.append" not taking parameter
I'm trying to find a way to import a module automatically in my script if the directory of the module is in the same directory of the script. Here is the code:
import sys
import os
cwd = os.getcwd()
...
1
vote
0
answers
42
views
How should I save file directories in python so I won't encounter any problems if I switch to another OS?
so for a long time I was a Windows guy so I just thought adding backslashes while writing directories in python for file manipulation would be okay. I however eventually found out that the UNIX ...
0
votes
2
answers
29
views
How to allow for multiple file names when searching through a directory in python?
How can I write something like:
module_path = os.path.join(root_dir,_dir,'Tests.py')
to be able to also take into considerations files named Test.py and test.py and tests.py?
If the file Tests.py ...
0
votes
2
answers
4k
views
How can I make an array of subdirectories in Python?
I want to make an array of subdirectories in Python. Here is an example layout and model list I would like to obtain.
Root
|
...
4
votes
3
answers
4k
views
How to import using a path that is a variable in Python
I am trying to make a program that will go through and visit an array of directories and run a program and create a file inside.
I have everything working except that I need to figure out a way to ...
1
vote
1
answer
165
views
Relative Path Python Error
My python file is in the folder 'RealData/Python/run.py'
What I need to do in run.py is to import another python file: plot_ensembles.py which is in the folder 'RealData/convolution/plot_ensembles.py'
...