AttributeError: module 'urllib3' has no attribute '__version__' error while executing py file

I'm very much new to Python and right now I'm trying to use Python for one of my automation tasks.

I'm trying to execute Execute.py while doing so I learned that my python setup should have modules requests (so downloaded 2.21.0),urllib3 (so downloaded 1.21.1), chardet(so downloaded 3.0.4).

My Python version is 3.7.3

When I execute my execute.py I get the following error:

 File "C:\Users\ABC\Downloads\python-3.7.3-embed-amd64\requests\__init__.py", line 87, in <module> check_compatibility(urllib3.__version__, chardet.__version__) AttributeError: module 'urllib3' has no attribute '__version__' 

So just like we have in chardet folder, I have created a version.py under urllib3 folder.

But still, I'm getting the same error.

Please, can someone help me with this? Which is taking my lot of time to find the resolution.

4 Answers

You can uninstall and then install again all required package, by pip uninstall and pip install .

you can also upgrade all specified packages to the newest available version. The handling of dependencies depends on the upgrade-strategy used (command require for this).

pip install --upgrade

You should use pip to install your libs, it will take care of the dependencies. It seems your urllib3 is not up to date...

Open a command prompt, and run:

pip install requests --upgrade 
3

My answer is about probably where i might have gone wrong.(Nothing wrong in above two answers)

I had installed executable Python,in which i dint have PIP (though its 3.7 version)

so i was struggling to install PIP and all other modules(since im am new)

So ---I had used Web based installation ()

which had PIP and set the Python PATH on the go using which i upgraded required modules like others answered here.

Which has come handy to do the rest of the job ,where i dint come across any issues while executing.

Thanks

I had the same problem with the requests. It was for A circular dependency occurs when two or more modules depend on each other. This is for the fact that each module is defined in terms of the other.

Please try to rename your file. The error for this error is usually due to a conflict with the file name where you are trying to import the requests module.

I was also having same problem, where my file name was token.py and I was trying to import the requests module. I changed the file name and it worked.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like