python - ImportError: cannot import name chardet -


hi have written python scrapper in importing requests , beautiful soup module . using python2.7 . crating windows executable (.exe) python script using py2exe module. have created setup.py following :

from distutils.core import setup import py2exe import requests  packages = [     'requests',     'requests.packages',     'requests.packages.chardet',     'requests.packages.urllib3',     'requests.packages.urllib3.packages',     'requests.packages.urllib3.contrib',     'requests.packages.urllib3.util',     'requests.packages.urllib3.packages.ssl_match_hostname', ]  setup(     console=['companyscrapper-1.6.py']     ) 

i have created .exe file running command "python setup.py py2exe". while running .exe file on window throwing following error:

traceback (most recent call last):   file "companyscrapper-1.6.py", line 13, in <module>   file "requests\__init__.pyc", line 58, in <module>   file "requests\utils.pyc", line 26, in <module>   file "requests\compat.pyc", line 7, in <module> importerror: cannot import name chardet 

i not undaerstand why chardet import error though have included package setup.py

thanks looking issue.

as can see traceback -

traceback (most recent call last):   file "companyscrapper-1.6.py", line 13, in <module>   file "requests\__init__.pyc", line 58, in <module>   file "requests\utils.pyc", line 26, in <module>   file "requests\compat.pyc", line 7, in <module> importerror: cannot import name chardet 

you have requests directory __init__.py . masking requests package library , when try import chardet or such thing requests library , tries search in local package, , not library one.

the best solution rename directory , local package requests else, name not conflict library packages.


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -