Python 3.2 won't import cookielib

I've searched everywhere for this and just can't seem to find the answer. I checked my python version and it is version 3.2. When I try to import cookielib

, I get:

ImportError: No module named cookielib

I saw that in Python 3.0 it was renamed to http.cookiejar

and that it will automatically import cookielib

.

I thought that maybe there was some wild error in my python config, so I decided to try and import http.cookiejar

like this one import http.cookiejar

. It does not work, and I get an error:

EOFError: EOF read where not expected

.

This is not the error I was expecting, because it import http.cookies

only imports fine.

Anyone have a solution to this problem? What am I missing?

Full error:

Traceback (most recent call last):
  File "C:\Users\Spencer\Downloads\selenium-2.20.0.tar\selenium-2.20.0\selenium-2.20.0\test", line 1, in <module>
    import urllib.request, urllib.parse, http.cookiejar
EOFError: EOF read where not expected

      

+3


source to share


3 answers


Automatic renaming business only applies if you are using 2to3 . Therefore you need import http.cookiejar

.



The error EOFError: EOF read where not expected

is only outputted by Python sorting. This is most likely caused by a race condition fixed in Python 3.3 where multiple processes were trying to write concurrently with the pyc file. Removing all .pyc files can be a workaround.

+9


source


The cookielib module has been renamed to http.cookiejar in Python 3.0. The 2to3 tool will automatically adapt imports when converting your sources to 3.0.



+1


source


My initial guess is that you have a corrupted library file. Inside your Python installation, browse lib/python3.2/http/cookiejar.py

and scroll down to the bottom. Mine (Python 3.2.2) ends up in a method definition save()

with

finally:
    f.close()

      

If you see anything else, your installation is likely to be corrupted and I recommend reinstalling it.

0


source







All Articles