getcwd

os.getcwd() raise Exception with django dev server

os.getcwd() raise Exception with django dev server Question: I have a django project running inside docker, and the service is up with the command of python manage.py runserver, with file autoreload open, and using threadings. My code invokes shutil.make_archive() which will then invoke os.getcwd(), and from time to time, os.getcwd() will raise FileNotFoundError, by searching …

Total answers: 1

Incorrect path with function getcwd()

Incorrect path with function getcwd() Question: I get the wrong path back. The Datafile is in D:… and get everytime the path C:Python27libsite-packagesxy back from python. I use the function path = getcwd() How can I fix it? Asked By: A.Boss || Source Answers: You may be executing the script in a different place than …

Total answers: 2

get script directory name – Python

get script directory name – Python Question: I know I can use this to get the full file path os.path.dirname(os.path.realpath(__file__)) But I want just the name of the folder, my scrip is in. SO if I have my_script.py and it is located at /home/user/test/my_script.py I want to return “test” How could I do this? Thanks …

Total answers: 3

How can I find script's directory?

How can I find script's directory? Question: Consider the following Python code: import os print os.getcwd() I use os.getcwd() to get the script file’s directory location. When I run the script from the command line it gives me the correct path whereas when I run it from a script run by code in a Django …

Total answers: 12