python - Import error in Flask (urllib in local path) -


am facing below error while trying import flask. similar questions posted had issues werkzeug versions

from urllib.request import parse_http_list _parse_list_header importerror: no module named request  file "init__.py", line 25, in <module>     flask import flask file "user/anaconda/lib/python2.7/site-packages/flask/__init__.py", line 17,    in <module>     werkzeug.exceptions import abort file "user/anaconda/lib/python2.7/site-packages/werkzeug/__init__.py", line     154, in <module>     __import__('werkzeug.exceptions') file "user/anaconda/lib/python2.7/site-packages/werkzeug/exceptions.py", line   71, in <module>     werkzeug.wrappers import response file "user/anaconda/lib/python2.7/site-packages/werkzeug/wrappers.py", line   26, in <module>     werkzeug.http import http_status_codes, \ file "user/anaconda/lib/python2.7/site-packages/werkzeug/http.py", line 28, in    <module>     urllib.request import parse_http_list _parse_list_header importerror: no module named request' 
  1. werkzeug version(i tried 10.1,10.4 ) still error remains.

  2. someone pointed out there might local copy of urllib2.. figured out there both urllib , urllib2 indeed in local path.. /library/frameworks/python.framework/versions/2.7/lib/python2.7

now not sure how proceed, should uninstall urllib/urllib2 ?

edit: solution listed in tried use relative imports, , broke import paths? doesn't work me. in case, tried importing urllib2 flask project , printing out file path, throws below exceptions

file "/user/__init__.py", line 25, in <module>   import urllib2 file "/user/anaconda/lib/python2.7/urllib2.py", line 94, in <module>   import httplib file "/user/anaconda/lib/python2.7/httplib.py", line 80, in <module>   import mimetools file "/user/anaconda/lib/python2.7/mimetools.py", line 6, in <module>   import tempfile file "/user/anaconda/lib/python2.7/tempfile.py", line 32, in <module>   import io _io file "/user/anaconda/lib/python2.7/io.py", line 51, in <module>   import _io 

importerror: dlopen(/user/anaconda/lib/python2.7/lib-dynload/_io.so, 2): symbol not found: __pyerr_replaceexception referenced from: /user/anaconda/lib/python2.7/lib-dynload/_io.so expected in: dynamic lookup

i had similar issue, , followed recommendation in solution adding from urllib2 import parse_http_list _parse_list_header before from flask import flask, got error message:

"/users/anaconda/lib/python2.7/io.py", line 51, in import _io  importerror: dlopen(/users/anaconda/lib/python2.7/lib-dynload/_io.so, 2):  symbol not found: __pycodecinfo_getincrementaldecoder  referenced from: /users/anaconda/lib/python2.7/lib-dynload/_io.so  expected in: dynamic lookup 

which resolved following solution:

  1. sudo find / -name _io.so
  2. i replaced /users/anaconda/lib/python2.7/lib-dynload/_io.so /usr/local/cellar/python/2.7.5/frameworks/python.framework/versions/2.7/lib/python2.7/lib-dynload/_io.so

it works me!


Comments