Cannot import name ProtocolError [RaspberryPi, Jasper] - python

I had installed sphinx and Jasper on my RPI. When I'm trying to start Jasper - i got this:
Traceback (most recent call last):
File "/home/pi/jasper/jasper.py", line 14, in <module>
from client import vocabcompiler, stt, jasperpath
File "/home/pi/jasper/client/stt.py", line 6, in <module>
import requests
File "/usr/local/lib/python2.7/dist-packages/requests/__init__.py", line 58, in <module>
from . import utils
File "/usr/local/lib/python2.7/dist-packages/requests/utils.py", line 25, in <module>
from .compat import parse_http_list as _parse_list_header
File "/usr/local/lib/python2.7/dist-packages/requests/compat.py", line 7, in <module>
from .packages import charade as chardet
File "/usr/local/lib/python2.7/dist-packages/requests/packages/__init__.py", line 3, in <module>
from . import urllib3
File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/__init__.py", line 16, in <module>
from .connectionpool import (
File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connectionpool.py", line 33, in <module>
from .connection import (
File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connection.py", line 41, in <module>
from .util import (
File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/__init__.py", line 18, in <module>
from .retry import Retry
File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/retry.py", line 4, in <module>
from ..exceptions import (
ImportError: cannot import name ProtocolError
Who can help me with this error? Thank you

you should
pip install urllib3

Related

when importing requests in pycharm, Import error occurs

When importing requests, the following error message occurs.
Traceback (most recent call last):
File "C:/Users/moter/PycharmProjects/compsci/alarm_project/get_events.py", line 1, in <module>
import requests
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\__init__.py", line 43, in <module>
import urllib3
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\__init__.py", line 7, in <module>
from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 11, in <module>
from .exceptions import (
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\exceptions.py", line 2, in <module>
from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\packages\six.py", line 199, in load_module
mod = mod._resolve()
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\packages\six.py", line 113, in _resolve
return _import_module(self.mod)
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\packages\six.py", line 82, in _import_module
__import__(name)
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 71, in <module>
import email.parser
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\email\feedparser.py", line 27, in <module>
from email._policybase import compat32
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\email\_policybase.py", line 9, in <module>
from email.utils import _has_surrogates
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\email\utils.py", line 33, in <module>
from email._parseaddr import quote
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\email\_parseaddr.py", line 16, in <module>
import time, calendar
File "C:\Users\moter\PycharmProjects\compsci\alarm_project\calendar.py", line 1, in <module>
from O365 import Account
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\site-packages\O365\__init__.py", line 8, in <module>
from .account import Account
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\site-packages\O365\account.py", line 1, in <module>
from .connection import Connection, Protocol, MSGraphProtocol
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\site-packages\O365\connection.py", line 9, in <module>
from requests import Session
ImportError: cannot import name 'Session' from 'requests' (C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\__init__.py)
CODE:
import requests
import sys
print(sys.path)
r = requests.get("https://openweathermap.org/")
print(r.status_code)
I have updated requests from both pip and pycharm itself. Furthermore, I have tried different python versions and the error persists. The error does not occur in IDLE however, but still occurs in other IDEs.
Note these lines in your traceback:
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\email\_parseaddr.py", line 16, in <module>
import time, calendar
File "C:\Users\moter\PycharmProjects\compsci\alarm_project\calendar.py", line 1, in <module>
from O365 import Account
You have a file named calendar.py which conflicts with something that the email module is trying to import. Your file calendar.py does then go on to import something from O365 which ends up trying to import Session from requests:
from O365 import Account
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\site-packages\O365\__init__.py", line 8, in <module>
from .account import Account
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\site-packages\O365\account.py", line 1, in <module>
from .connection import Connection, Protocol, MSGraphProtocol
File "C:\Users\moter\AppData\Local\Programs\Python\Python37\lib\site-packages\O365\connection.py", line 9, in <module>
from requests import Session
Which ends up being a circular import, caused by the conflicting filename. So simply rename your calendar.py, e.g. to mycalendar.py and your issue should be solved

Receiving error messages while importing nltk

I was successfully able to install nltk and I have all the prerequisites installed as well.
Nonetheless I have been receiving error messages like these while importing nltk.
>>> import nltk
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
import nltk
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\nltk\__init__.py", line 128, in <module>
from nltk.chunk import *
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\nltk\chunk\__init__.py", line 157, in <module>
from nltk.chunk.api import ChunkParserI
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\nltk\chunk\api.py", line 13, in <module>
from nltk.parse import ParserI
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\nltk\parse\__init__.py", line 79, in <module>
from nltk.parse.transitionparser import TransitionParser
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\nltk\parse\transitionparser.py", line 21, in <module>
from sklearn.datasets import load_svmlight_file
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\sklearn\datasets\__init__.py", line 6, in <module>
from .base import load_breast_cancer
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\sklearn\datasets\base.py", line 20, in <module>
from ..utils import Bunch
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\sklearn\utils\__init__.py", line 11, in <module>
from .validation import (as_float_array,
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\sklearn\utils\validation.py", line 23, in <module>
from ..externals.joblib import Memory
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\sklearn\externals\joblib\__init__.py", line 127, in <module>
from .parallel import Parallel
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\sklearn\externals\joblib\parallel.py", line 25, in <module>
from ._multiprocessing_helpers import mp
File "C:\Users\Saurav\AppData\Local\Programs\Python\Python36-32\lib\site-
packages\sklearn\externals\joblib\_multiprocessing_helpers.py", line 24, in
<module>
_sem = mp.Semaphore()
AttributeError: module 'multiprocessing' has no attribute 'Semaphore'

Why caffe raises this error? ImportError: cannot import name _remove_dead_weakref

I have written a Python layer that puts bottom into an array (im), squeezes the dimension and prints the shape of array (im_shape).
caffe is raising the following error, even after recompiling it again, I am getting this error. Could someone please help me why this error is shown?
I
1222 01:37:59.268040 3566 layer_factory.hpp:77] Creating layer print_shape
Traceback (most recent call last):
File "/home/user/caffe/python/print_layer.py", line 1, in <module>
import caffe
File "/home/user/caffe/python/caffe/__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
File "/home/user/caffe/python/caffe/pycaffe.py", line 11, in <module>
import numpy as np
File "/home/user/anaconda2/envs/testcaffe/lib/python2.7/site-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/home/user/anaconda2/envs/testcaffe/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/home/user/anaconda2/envs/testcaffe/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/home/user/anaconda2/envs/testcaffe/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/home/user/anaconda2/envs/testcaffe/lib/python2.7/site-packages/numpy/core/__init__.py", line 74, in <module>
from numpy.testing.nosetester import _numpy_tester
File "/home/user/anaconda2/envs/testcaffe/lib/python2.7/site-packages/numpy/testing/__init__.py", line 10, in <module>
from unittest import TestCase
File "/home/user/anaconda2/envs/testcaffe/lib/python2.7/unittest/__init__.py", line 64, in <module>
from .main import TestProgram, main
File "/home/user/anaconda2/envs/testcaffe/lib/python2.7/unittest/main.py", line 7, in <module>
from . import loader, runner
File "/home/user/anaconda2/envs/testcaffe/lib/python2.7/unittest/runner.py", line 7, in <module>
from .signals import registerResult
File "/home/user/anaconda2/envs/testcaffe/lib/python2.7/unittest/signals.py", line 2, in <module>
import weakref
File "/home/user/anaconda2/envs/testcaffe/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref

ImportError: cannot import name 'multiarray' [New Edit this are good]

I have this error and I do not know how to fix it I have tried many meneras and I do not know how I created new post because the other was badly
Traceback (most recent call last):
File "run.py", line 9, in <module>
from layer import MacLayer
File "/root/MacBot/layer.py", line 5, in <module>
from app import main
File "/root/MacBot/app/main.py", line 8, in <module>
from app.yesno.yesno import YesNo
File "/root/MacBot/app/yesno/yesno.py", line 2, in <module>
import moviepy.editor as mp
File "/usr/local/lib/python3.5/dist-packages/moviepy-0.2.2.11-py3.5.egg/moviepy/editor.py", line 22, in <module>
from .video.io.VideoFileClip import VideoFileClip
File "/usr/local/lib/python3.5/dist-packages/moviepy-0.2.2.11-py3.5.egg/moviepy/video/io/VideoFileClip.py", line 3, in <module>
from moviepy.video.VideoClip import VideoClip
File "/usr/local/lib/python3.5/dist-packages/moviepy-0.2.2.11-py3.5.egg/moviepy/video/VideoClip.py", line 15, in <module>
import numpy as np
File "/usr/lib/python3/dist-packages/numpy/__init__.py", line 153, in <module>
from . import add_newdocs
File "/usr/lib/python3/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/lib/python3/dist-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/lib/python3/dist-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 6, in <module>
from . import multiarray
ImportError: cannot import name 'multiarray'
Easiest solution is to use anaconda available from continuum.io/downloads
then you aren't messing with compiling this yourself.

Error importing numpy in python 2.7

I am having trouble importing numpy into my project. I am using python 2.7.10 and when i try to run the script i get the error :
Traceback (most recent call last):
File "test.py", line 2, in <module>
import numpy as np
File "/usr/local/lib/python2.7/site-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/usr/local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python2.7/site-packages/numpy/core/__init__.py", line 58, in <module>
from numpy.testing import Tester
File "/usr/local/lib/python2.7/site-packages/numpy/testing/__init__.py", line 14, in <module>
from .utils import *
File "/usr/local/lib/python2.7/site-packages/numpy/testing/utils.py", line 15, in <module>
from tempfile import mkdtemp
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", line 32, in <module>
import io as _io
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions /2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/li b/python2.7/lib-dynload/_io.so
Expected in: flat namespace
in /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/li b/python2.7/lib-dynload/_io.so
Any ideas on whats causing the issue?

Categories