AttributeError: module 'pathlib' has no attribute '_Accessor'

1.2k Views Asked by At

When i use python 3.9, everything is OK

but when i use python 3.11, show error like this:

Traceback (most recent call last):

  
File "C:\project\test\tools\test.py", line 3, in <module>
    from artifactory import ArtifactoryPath
  
File "C:\Users\ba\AppData\Local\Programs\Python\Python311\Lib\site-packages\artifactory.py", line 406, in <module>
    class _ArtifactoryAccessor(pathlib._Accessor):
                               ^^^^^^^^^^^^^^^^^
AttributeError: module 'pathlib' has no attribute '_Accessor'

python code like this:

from artifactory import ArtifactoryPath

python version:

Python version is 3.11.3 (tags/v3.11.3:f3909b8, Apr  4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)]

artifactory version:

Name: artifactory

Version: 0.1.17

Summary: A Python to Artifactory interface

how to fix this issue?

I wonder to know how to fix this problem or anyother lib to replace

1

There are 1 best solutions below

0
Shah Wali On BEST ANSWER

The error message you're seeing, "AttributeError: module 'pathlib' has no attribute '_Accessor'," indicates that you are trying to access an attribute or method called _Accessor in the pathlib module, but Python cannot find it because it doesn't exist.

The pathlib module in Python is used for working with file paths and directories, and it doesn't have an attribute called _Accessor. If you are encountering this error, it is likely due to a mistake in your code.

Here are some common reasons why you might encounter this error and how to resolve them:

  1. Typo: Check your code for any typos in the attribute name. Make sure you are using the correct attribute or method name.

  2. Incorrect Usage: Verify that you are using the pathlib module correctly. Make sure you have imported it correctly and are using its classes and methods in the intended way.

  3. Compatibility: In rare cases, this error could be caused by compatibility issues between Python versions or packages. Ensure that your Python installation is up-to-date and that you are using compatible versions of any third-party packages that use pathlib.

Without seeing your specific code, it's challenging to provide a more detailed solution. If you can provide more context or code snippets, I would be happy to help you further troubleshoot the issue.