Linked Questions
24 questions linked to/from How to refer to relative paths of resources when working with a code repository
0
votes
0
answers
4k
views
How do I load a UI file into a python file? [duplicate]
I'm a new programmer, sorry If my question is too basic
I created a mybutton.ui file in Qt Designer, Then I want to run it through my python app.
the mybutton.ui file is next to Qt-Designer-GUI-Code....
3
votes
0
answers
3k
views
How to load Qt Designer UI file [duplicate]
import sys
from PyQt5.uic import loadUi
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QDialog, QApplication, QWidget
from PyQt5.QtGui import QPixmap
from PyQt5 import uic
class WelcomeScreen(...
0
votes
1
answer
1k
views
How to load a file in module without hard coding path [duplicate]
Suppose I have a collection of functions in a module called my_functions.py. One of these functions must load data from a text file that is stored in the same directory as my_functions.py. For ...
266
votes
7
answers
165k
views
How to read a (static) file from inside a Python package?
How can I read a file that is inside my Python package?
A package that I load has a number of templates (text files used as strings) that I want to load from within the program. But how do I specify ...
180
votes
16
answers
132k
views
Unit testing Bash scripts
We have a system that has some Bash scripts running besides Java code. Since we are trying to test everything that could possibly break, and those Bash scripts may break, we want to test them.
The ...
45
votes
5
answers
85k
views
How to resolve relative paths in python?
I have Directory structure like this
projectfolder/fold1/fold2/fold3/script.py
now I'm giving script.py a path as commandline argument of a file which is there in
fold1/fold_temp/myfile.txt
So ...
6
votes
2
answers
6k
views
Pyinstaller EXE's __file__ refers to a .py file
Situation: My Python script has a line of code that copies itself to another directory
shutil.copyfile(os.path.abspath(__file__), newPath)
Problem: The script is then compiled into an EXE and ran. ...
6
votes
1
answer
21k
views
Docker Python script can't find file
I've successfully built a Docker container and copied my application's files into the container in the Dockerfile. However, I am trying to execute a Python script that references an input file (that ...
4
votes
3
answers
3k
views
Why can't the Python command "subprocess.Popen" find the jar file to run?
I'm trying to run code from this repo: https://github.com/tylin/coco-caption, specifically from https://github.com/tylin/coco-caption/blob/master/pycocoevalcap/tokenizer/ptbtokenizer.py, line 51-52:
...
4
votes
4
answers
2k
views
Code works in Idle but getting an error in VS Code
So I am writing a code where I need to import a file. Both the python code file and the file I need to import are in the same directory thus I haven't specified the whole path.
The code works fine in ...
1
vote
2
answers
5k
views
How to call relative path of batch file from python
How do I call the relative path of batch file from python?
My python script 'Script.py' is in the directory "d:\2014\python\script.py"
from this file i would like to call a batch file "d:\2014\input\...
6
votes
1
answer
2k
views
How can I access relative paths in Python 2.7 when imported by different modules
The Goal:
Access / Write to the same temp files when using a common utility function called from various python modules.
Background:
I am using the python Unittest module to run sets of custom tests ...
-3
votes
2
answers
5k
views
Python doesn't recognize jpg image file/directory
I can't get this image to be displayed in a tkinter gui because it doesn't recognize the image file or directory, here is my code:
import tkinter as tk
from PIL import ImageTk, Image
root = tk.Tk()
...
4
votes
1
answer
3k
views
Python - [Errno 2] No such file or directory,
I am trying to make a minor modification to a python script made by my predecessor and I have bumped into a problem. I have studied programming, but coding is not my profession.
The python script ...
0
votes
2
answers
3k
views
Get resource from python resource root
I am using the PyCharm IDE. I marked a folder as a resource root and wanted to get a file from its directory and was wondering the appropriate way to do so.
In Java, you can use getClass()....