I have a python script that produces the following error when run:
import urllib2
File "C:\Python27\lib\urllib2.py", line 94, in <module>
import httplib
File "C:\Python27\lib\httplib.py", line 73, in <module>
from urlparse import urlsplit
File "C:\Python27\lib\urlparse.py", line 119, in <module>
from collections import namedtuple
ImportError: cannot import name namedtuple
I also use the openpyxl
package, located in C:\Python27\Lib\site-packages, which contains a collections
folder with a __init__.py
file. I figured this is what causes the problem, because it may be preventing the python 2.7 collections module from being imported.
What can I do to fix this problem?
This can also happen if your local script contains a "collections" module due to the way Python handles relative and absolute imports.
I had the same issue but this worked when I changed Collection Package to a simple collection directory.
I just deleted the init.py file from the collections
this can be due to the package name Collections. this can be also resolved by renaming Collection Package to othername.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With