AttributeError: module 'os' has no attribute 'PathLike'

2.3k Views Asked by At

I want to run os.PathLike in python 3.5. Unfortunately this is not available in python 3.5. Is there a turnaround in which I can run this command in python 3.5 without upgrading the python version.

1

There are 1 best solutions below

0
Christian Bangert On

Welcome to dependency hell. Since python 3.5 is depreciated many new version of modules are using 3.6 syntax which causes problems like this. I just resolved a similar issue. Check the stack trance and find which module is throwing that error then delete that version of it and find an older version that's compatible.

In my case python modules were updated and the certifi module was breaking pip3 with the same error you're seeing. I found a compatible version of it on https://pypi.org/project/certifi. Then deleted the module like this

sudo rm -rf <python3.5_path>/dist-packages/certifi

After this I was able to use python3 -m pip e.g.

sudo python3 -m pip uninstall requests
python3 -m pip install requests==2.19.0   # This reinstalls certifi-2022.6.15-py3-none-any.whl which breaks in python 3.5
rm -rf /home/ssm-user/.local/lib/python3.5/site-packages/certifi
python3 -m pip install certifi==2021.10.8