Questions tagged [pathlib]

This tag is for questions about the Python built-in library pathlib, which offers classes representing filesystem paths with semantics appropriate for different operating systems.

This module offers classes representing filesystem paths with semantics appropriate for different operating systems. Path classes are divided between Pure paths, which provide purely computational operations without I/O, and Concrete paths, which inherit from pure paths but also provide I/O operations.

Its strength lies in that it offers a powerful Object Oriented interface for working with paths, as opposed to the string-based interface offered by os.path.

This table offers a mapping between various os functions to their corresponding PurePath/Path equivalent.

635 questions
0
votes
1 answer

Copy a file to a new folder and rename it in python

I’m trying to copy an xls file to a new folder and there renaming it as xlsx file but I’m getting several errors. I want to change the name because the xls file could be corrupt. The input file is given by the user and I want to create the new…
0
votes
1 answer

Failed to read images when folder has special characters on name

Basically I'm using locateOnScreen() function, which is from pyautogui to read an image and then find in the screen by: import os import pathlib import pyautogui Image = os.path.join(os.path.sep, pathlib.Path(__file__).parent.resolve(), 'static',…
Guilherme Matheus
  • 573
  • 10
  • 30
0
votes
1 answer

How can I display the ETA and speed of nested TQDM progress bars?

I am trying to display two TQDM progress bar in Jupyter Notebook. I'm using VSC with Jupyter Notebook and Python 3.9. I have the following code: from pathlib import Path from tqdm.autonotebook import tqdm outerdir = Path('some/path') dirs =…
Neele22
  • 373
  • 2
  • 18
0
votes
4 answers

Local file upload progress bar in console using Python

I need to upload a file and show its stats to the user (as it shows on the console). Didn't find any library for this, the function can be as simple as showing the uploaded percentage (uploaded/filesize*100) and showing the uploaded size (20/50MB)…
Ali Abdi
  • 408
  • 7
  • 21
0
votes
1 answer

ImportError: No module named pathlib Windows OS and Python version 3.8

Hi im trying to run a venv for my project. Everythin goes well install requirments and creating a my venv. The problem is that when i try to make a manage.py migrate i get this error. Ive looked everywhere and i got python version 3.8 installed.…
The
  • 73
  • 7
0
votes
2 answers

I'm trying to read pdf one by one and then converting it into dataframe

I've used 'fitz' from Pymupdf module to extract data and then with pandas converting the extracted data to dataframe. #Code to read multiple pdfs from the folder: from pathlib import Path # returns all file paths that has .pdf as extension in the…
User1011
  • 143
  • 1
  • 10
0
votes
0 answers

Sphinx: "man_pages" config value references unknown document

I am a beginner so maybe this question sounds stupid. Anyway, I have a make.bat file which you can pass in the builder name to use and it invokes below command: set SPHINXBUILD=sphinx-build set SOURCEDIR=source set BUILDDIR=build %SPHINXBUILD% -M…
Willy
  • 9,848
  • 22
  • 141
  • 284
0
votes
3 answers

Generate string of only file names from directory/subdirectory in Python, no directory address

NOTE: SEE EDITED VERSION OF QUESTION AT THE BOTTOM RE USING pathlib I would like to iterate through directory/subdirectories (Mac) and list all filenames as a string. I can do this fine but the string includes directory info, eg…
Tala Kap
  • 17
  • 4
0
votes
1 answer

How to save plot to new Folder

I would like to save my matplotlib plot to the new generated Folder. I just dont get it to save my plot to this path... This is my Code so far: now = datetime.now() current_time = now.strftime("%m_%d_%Y, %H_%M_%S") dir_name = "Messdaten " +…
Daniel
  • 163
  • 12
0
votes
1 answer

How to download exe file from Streamlit?

I made a .py script converted it to a .exe file to make a windows desktop app using pyinstaller. I did this: pyinstaller --onefile -w test.py How can a user download this app using Streamlit? Specifically using Streamlit download button. I tried…
JoraSN
  • 332
  • 2
  • 14
0
votes
1 answer

Comparing two text files inside zip files using python

I want to compare two text files with same name and same relative path inside two different zip files using python. I have been trying to search various ways and found none of the top solutions available work in my case. My code: from zipfile import…
Asif Iqbal
  • 421
  • 3
  • 13
0
votes
1 answer

How do I get the previous second folder or the folder with a certian name

I want to get a certain folder, the name of this is 'certainName' or it is two folder previous. myFolder = 'certainName' myPath = r'C:/Documents/something/certainName/anotherFolder/folder' p =…
Test
  • 571
  • 13
  • 32
0
votes
0 answers

Python pathlib not accepted by Pandas.ExcelWriter(..)

After finally getting Pandas to output my file as a spreadsheet (silly issue), I ran into an issue with the file path input not being read properly, even as a raw string. Eventually I stumbled upon the pathlib library, and it's been successful in…
maertsoi
  • 103
  • 7
0
votes
1 answer

Python pathlib error while trying to access AWS lambda environment file during runtime

I'm using a python 3.9 Lambda function with a layer-based module. The module requires an absolute path to a JSON file be provided which it uses to read/write data during runtime. The access occurs infrequently. My thought was to create the json file…
Jwelliver
  • 3
  • 2
0
votes
0 answers

Pathlib issue: iteration over pathlist ist skipped -> Why?

I would be happy to learn why the for loop is not being executed? Event though a list of WindowsPaths gets printed. Thank you very much in advance. from pathlib import Path pathlist =…
quest4stack
  • 13
  • 1
  • 3