question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] AttributeError: 'WindowsPath' object has no attribute 'read_text'

See original GitHub issue

setuptools version

setuptools==60.7.0

Python version

3.8.10

OS

Windows 10

Additional environment information

No response

Description

There’s regression in compare to previous setuptools==60.6.0 (which works)

E.g. installing latest setuptools and pip and then installing e.g. pathlib fails with following error: AttributeError: 'WindowsPath' object has no attribute 'read_text'

Expected behavior

it works

How to Reproduce

  1. install latest pip (22.0.2)
  2. install latest setuptools (60.7.0)
  3. install pathlib using pip

Output

python -m pip install -U pip
(cut)
pip install -U setuptools
(cut)

(venv) C:\Temp\setuptools>pip install -U pathlib
Collecting pathlib
  Using cached pathlib-1.0.1.tar.gz (49 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 14, in <module>
        File "c:\temp\setuptools\venv\lib\site-packages\setuptools\__init__.py", line 16, in <module>
          import setuptools.version
        File "c:\temp\setuptools\venv\lib\site-packages\setuptools\version.py", line 1, in <module>
          import pkg_resources
        File "c:\temp\setuptools\venv\lib\site-packages\pkg_resources\__init__.py", line 74, in <module>
          from pkg_resources.extern.jaraco.text import (
        File "c:\temp\setuptools\venv\lib\site-packages\pkg_resources\_vendor\jaraco\text\__init__.py", line 227, in <module>
          lorem_ipsum: str = files(__name__).joinpath('Lorem ipsum.txt').read_text()
      AttributeError: 'WindowsPath' object has no attribute 'read_text'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cz6acecommented, Feb 2, 2022

Hi @cz6ace, that you very much for bringing this up.

Is this error related to the fact you are installing pathlib specifically?

We have the pathlib as a dependency, probably from hexrec package. Now I can see the most recent version got rid of it: “Removed dependency of legacy pathlib package; using Python’s own module instead.”

Can you reproduce this error without installing an external pathlib (or any package with a dependency on it)?

No, just with pathlib

At the end - we can easily fix to upgrade the hexrec package which do not rely on obsolete pathlib any more.

No one should be using pathlib.

This ticket can be closed if I understand it correctly.

1reaction
partheacommented, Feb 2, 2022

I’m using the built-in pathlib so it is a different issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python docx AttributeError: 'WindowsPath' object has no ...
When I wrapped the PDF file in FileIO like so FileIO(pdf_path, "rb") the error went away and I was able to process the...
Read more >
AttributeError: 'WindowsPath' object has no attribute 'read' · ...
This "AttributeError: 'WindowsPath' object has no attribute 'read'" from #273 ... Update: installed pydub 0.23.1 and keep getting the error:
Read more >
python-docx AttributeError: 'WindowsPath' object has no ...
After Debugging I got this Error. It only occurs on line 10. Exception has occurred: AttributeError 'WindowsPath' object has no attribute ...
Read more >
I get the error : 'WindowsPath' object has no attribute 'read', ...
I get the error : 'WindowsPath' object has no attribute 'read', any ideas ? ... Learn on the go with our new app....
Read more >
attributeerror: module 'posixpath' has no attribute 'splittext'
I'm following lesson 5 in Google Colab, trying to use Path, but I'm getting the following error: AttributeError: 'PosixPath' object has no attribute...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found