Linked Questions

603 votes
26 answers
637k 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....
Ray's user avatar
  • 194k
863 votes
15 answers
1.5m views

cd is the shell command to change the working directory. What is the equivalent in Python?
too much php's user avatar
  • 91.4k
0 votes
1 answer
1k views

I have a script that runs multiple instances of Python Scrapy crawlers, Crawlers are int /root/crawler/batchscript.py and in /root/crawler/ I have that scrapy crawler. Crawlers are working perfectly ...
Umair Ayub's user avatar
  • 21.7k
-3 votes
1 answer
260 views

I am running python 3.7 in Wing IDE as an administrator. The python file is in the same folder (Documents) as the textdoc file. This is the python code I have: file = open("textdoc.txt", "r") ...
Clock's user avatar
  • 35
0 votes
1 answer
99 views

I have a python script saved in a directory. When I run it from its folder it works as expected. However, when I run it through an interface (Unraid's User Script plug-in's "Run Script" ...
GFL's user avatar
  • 1,486
413 votes
16 answers
200k views

I would like to see what is the best way to determine the current script directory in Python. I discovered that, due to the many ways of calling Python code, it is hard to find a good solution. Here ...
bogdan's user avatar
  • 9,474
26 votes
6 answers
88k views

Coming from R, using setwd to change the directory is a big no-no against reproducibility because others do not have the same directory structure as mine. Hence, it's recommended to use relative path ...
Heisenberg's user avatar
  • 8,896
11 votes
1 answer
15k views

I have a python script that parses all of the C++ source files in the project's directory, looks for some stuff in the files, and then generates a file. This python script works fine, but I want it ...
irfna's user avatar
  • 545
6 votes
2 answers
8k views

I would like to download 100+ email from gmail as pdf. It would be too long to manually download all of them via the print option in gmail. This python script retrieves the emails in the chosen label....
MagTun's user avatar
  • 6,245
0 votes
1 answer
2k views

In batch there is a command %~dp0 which mean change the directory to the script directory, for example: Batch file is in desktop, if you use %~dp0 the directory instantly go to the C:\Users\Windows\...
BransRma's user avatar
2 votes
1 answer
6k views

I want to execute python script by supervisor. I set up the directory option in supervisord.conf and I used relative path in command option like this. [supervisord] http_port=/var/tmp/supervisor....
nemupm's user avatar
  • 53
4 votes
2 answers
2k views

I have finished a program in Python and I intend for it to be run from my RPi every n hours. This will be my first time running such program/script in this way and I would like to know if there is ...
tlre0952b's user avatar
  • 751
1 vote
2 answers
1k views

I am creating a Python package with multiple modules. I want to make sure that when I import modules within the package that they are importing only from the package and not something outside the ...
jlconlin's user avatar
  • 15.2k
1 vote
1 answer
2k views

I’m a new python user and have written a python script that prompts for the name of a text file (.txt) to be opened and read by the program. name = raw_input("Enter file:") if len(name) < 1: ...
Mabyn's user avatar
  • 317
0 votes
4 answers
939 views

I would like to change the folder where a file is created in my Python Script. Just now I have the next line: file = open("scraping.txt", "w") but the problem is that scraping.txt is saved in the ...
Alex's user avatar
  • 537

15 30 50 per page