Linked Questions

75 questions linked to/from Relative paths in Python
603 votes
26 answers
638k views

I have scripts calling other script files but I need to get the filepath of the file that is currently running within the process. For example, let's say I have three files. Using execfile: script_1....
0 votes
1 answer
3k views

I ́m trying to write a file into the %temp%-Folder, but the username of every User is different. Does Python have a function or some kind like that to join the folder? I tried it like this, but I get ...
0 votes
0 answers
4k views

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

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(...
-1 votes
1 answer
1k views

I am doing a vehicle license plate detection and recognition project. My code was working perfectly fine and then all of a sudden it stopped working. It seems as if opencv stopped working completely. ...
0 votes
1 answer
1k views

Im use this path to go back 1 directory (back to directory 'dsa') with open('../file.txt','r',encoding='utf-8') as f: print(f.read()) I get this error Traceback (most recent call last): File &...
honkaisenbai's user avatar
0 votes
1 answer
1k views

The title may not be the best description of what I'm trying to do. I made a few simple lines of code to run a .exe, in this case the adobe reader installer. import os os.system('"D:/Python ...
Ben Hille's user avatar
1 vote
0 answers
108 views

For example: in the file main/main.py import core.fun as f f.script() and in the file main/core/fun.py: def script(): f = open('test.txt','r') where a file test.txt is present in the folder main/...
0 votes
0 answers
82 views

I am writing a python library with the following file structure: main_folder | main.py | module_subfolder/ | | | module.py | resources/ | ...
0 votes
0 answers
66 views

How can I read the /billy/var/text.txt into b.py The directory structure is: /billy/b.py /billy/var/text.txt /sally/s.py s.py import sys, os sys.path.append('..') from billy import b print('s.py - ...
Rhys's user avatar
  • 5,418
0 votes
0 answers
75 views

I'm currently experiencing problems accessing files inside my python project depending on where I call the program from. I can't seem to find an appropriate answer using the search bar. I have a ...
Derek1st's user avatar
981 votes
19 answers
1.5m views

What is the best way to open a file as read/write if it exists, or if it does not, then create it and open it as read/write? From what I read, file = open('myfile.dat', 'rw') should do this, right? It ...
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 ...
1081 votes
12 answers
1.6m views

Given a path such as "mydir/myfile.txt", how do I find the file's absolute path in Python? E.g. on Windows, I might end up with: "C:/example/cwd/mydir/myfile.txt"
429 votes
16 answers
663k views

The below code will not join, when debugged the command does not store the whole path but just the last entry. os.path.join('/home/build/test/sandboxes/', todaystr, '/new_sandbox/') When I test this ...
chrisg's user avatar
  • 41.8k

15 30 50 per page
1
2 3 4 5