About 293,000 results
Open links in new tab
  1. python - Find the current directory and file's directory - Stack …

    To get the full path to the directory a Python file is contained in, write this in that file: import os dir_path = os.path.dirname(os.path.realpath(__file__)) (Note that the incantation above won't …

  2. how do you get the current local directory in python

    current_working_directory = os.getcwd().split("/") local_working_directory = current_working_directory[len(current_working_directory)-1] this works for me. none of the …

  3. python - How can I find script's directory? - Stack Overflow

    Feb 8, 2011 · If the script directory is not available (e.g. if the interpreter is invoked interactively or if the script is read from standard input), path[0] is the empty string, which directs Python to …

  4. python - How do I get the full path of the current file's directory ...

    Python 3. For the directory of the script being run: import pathlib pathlib.Path(__file__).parent.resolve() For the current working directory: import pathlib …

  5. How can I find where Python is installed on Windows?

    Mar 15, 2009 · @ScottSiddall so you are saying, you know Python is installed on your machine, but its not in PATH, you need to find it somehow! there are many ways, one would be to use …

  6. Getting a list of all subdirectories in the current directory

    Jun 10, 2009 · import os def get_sub_directory_paths(start_directory, sub_directories): """ This method iterates through all subdirectory paths of a given directory to collect all directory paths. …

  7. How to get the current directory in python? - Stack Overflow

    Nov 23, 2021 · I'm trying to get the current directory using the OS module, like that: directory=os.getcwd() However ...

  8. Python can't find module in the same folder - Stack Overflow

    Jul 13, 2014 · I had a big folder of Python practice projects open in VS Code and I was having big problems with finding things in the same directory. My problem was that, in the terminal, I …

  9. Browse files and subfolders in Python - Stack Overflow

    Apr 28, 2011 · The first parameter is the directory pathname. This will change for each subdirectory. This answer is based on the 3.1.1 version documentation of the Python Library. …

  10. How to find the real user home directory using python?

    The accepted answer was not working for me. I needed to find the user directory and I wanted it to work with and without sudo. In Linux, my user directory is "/home/someuser" but my root …

Refresh