Python - Import _brcypt - PyUnicodeUCS4_FromUnicode - python-2.7

I need to install/use paramiko in a server with python 2.7
I install paramiko with pip without any problem but, when i try to import it, it´s fails
The error is:
ImportError: /usr/lib64/python2.7/site-packages/_cffi_backend.so: undefined symbol: PyUnicodeUCS4_FromUnicode
It´s an old machine without any documentation, it´s a mess.... i use paramiko in other servers without any problem
import paramiko
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.7/site-packages/paramiko/init.py", line 22, in
from paramiko.transport import SecurityOptions, Transport
File "/usr/lib/python2.7/site-packages/paramiko/transport.py", line 90, in
from paramiko.ed25519key import Ed25519Key
File "/usr/lib/python2.7/site-packages/paramiko/ed25519key.py", line 17, in
import bcrypt
File "/usr/lib64/python2.7/site-packages/bcrypt/init.py", line 25, in
from . import _bcrypt
ImportError: /usr/lib64/python2.7/site-packages/_cffi_backend.so: undefined symbol: PyUnicodeUCS4_FromUnicode
error message:
ImportError: /usr/lib64/python2.7/site-packages/_cffi_backend.so: undefined symbol: PyUnicodeUCS4_FromUnicode

Related

Invalid syntax error using Requests library with Python 2.7

I'm using the Requests library with Python 2.7 and get the following error:
Traceback (most recent call last):
File "/home/user/Documents/workspaces/controller/main.py", line 2, in <module>
import requests
File "/usr/local/lib/python2.7/dist-packages/requests/__init__.py", line 45, in <module>
from .exceptions import RequestsDependencyWarning
File "/usr/local/lib/python2.7/dist-packages/requests/exceptions.py", line 11, in <module>
from .compat import JSONDecodeError as CompatJSONDecodeError
File "/usr/local/lib/python2.7/dist-packages/requests/compat.py", line 14, in <module>
import charset_normalizer as chardet
File "/usr/local/lib/python2.7/dist-packages/charset_normalizer/__init__.py", line 24, in <module>
from .api import from_bytes, from_fp, from_path, normalize
File "/usr/local/lib/python2.7/dist-packages/charset_normalizer/api.py", line 38
sequences: bytes,
^
SyntaxError: invalid syntax
I installed Requests with the following command:
sudo pip install requests -t /usr/local/lib/python2.7/dist-packages
The file I'm running is just main.py with the content:
import json
import requests
if __name__ == "__main__":
print('hello world')
I have both Python 3.6 and 2.7 installed and selected Python 2.7 as the interpreter in VS Code.
I just ran into this issue; the package is expecting to be executed with Python 3, not Python 2.

python PyUserInput import error

Hi I am trying to download PyUserInput, I downloaded it using pip and there were no errors. When I try to import it into a file in give me an error which I do not understand. I have a basic understanding of python and pip.Any help will be much appreciated.I have pasted the error I get below.
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from pymouse import PyMouse
File "/usr/local/lib/python2.7/dist-packages/pymouse/__init__.py", line 41, in <module>
from .x11 import PyMouse, PyMouseEvent
File "/usr/local/lib/python2.7/dist-packages/pymouse/x11.py", line 16, in <module>
from Xlib.display import Display
File "/usr/local/lib/python2.7/dist-packages/Xlib/display.py", line 26, in <module>
from six import create_unbound_method
ImportError: cannot import name create_unbound_method
Thanks
I had the same problem on old raspberry pi image and upgrading six solved the issue for me:
sudo pip install six --upgrade

import asgi_redis: ImportError: No module named _compat

I can import asgi_redis on my local server fine but I get the error in the title when i try to import asgi_redis on my production server (heroku, using heroku run bash). Both have the same version of asgi_redis.
Here is the full traceback:
>>> import asgi_redis
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/app/.heroku/python/lib/python2.7/site-packages/asgi_redis/__init__.py", line 1
, in <module>
from .core import RedisChannelLayer
File "/app/.heroku/python/lib/python2.7/site-packages/asgi_redis/core.py", line 10, i
n <module>
from redis._compat import b
ImportError: No module named _compat
Does anyone know what is going on here? Thanks in advance.
I also have redis installed, redis 2.6.0, FWIW
local server had latest redis, production did not. upgraded redis on production and error is gone

ImportError from greenlet with Python 2.7.3 in virtualenv

I installed locustio
pip install locustio
Once installed, I tried running
locust --help
But I get the following error:
Traceback (most recent call last):
File "/home/vagrant/.virtualenvs/chalktalk-legacy/bin/locust", line 7, in <module>
from locust.main import main
File "/home/vagrant/.virtualenvs/chalktalk-legacy/local/lib/python2.7/site-packages/locust/__init__.py", line 1, in <module>
from core import HttpLocust, Locust, TaskSet, task
File "/home/vagrant/.virtualenvs/chalktalk-legacy/local/lib/python2.7/site-packages/locust/core.py", line 1, in <module>
import gevent
File "/home/vagrant/.virtualenvs/chalktalk-legacy/local/lib/python2.7/site-packages/gevent/__init__.py", line 49, in <module>
from gevent.hub import get_hub, iwait, wait, PYPY
File "/home/vagrant/.virtualenvs/chalktalk-legacy/local/lib/python2.7/site-packages/gevent/hub.py", line 11, in <module>
from greenlet import greenlet, getcurrent, GreenletExit
ImportError: /home/vagrant/.virtualenvs/chalktalk-legacy/local/lib/python2.7/site-packages/greenlet.so: undefined symbol: _PyTrash_thread_deposit_object
Is the solution to rebuild gevent? If so, how does one go about rebuilding greenlet in debian virtualenv with python 2.7.3? If not, how do I solve this issue without upgrading python?

ImportError: No module named if trying to execute from command line

I am getting following error
D:\pythongui>C:\Python27\python.exe D:/pythongui/controller/MainController.py
Traceback (most recent call last):
File "D:/pythongui/controller/MainController.py", line 5, in <module>
from view.MainView import Launcher
ImportError: No module named view.MainView
when I am executing the following command in terminal
C:\Python27\python.exe D:/pythongui/controller/MainController.py
But the same code is working in pycharm without any error.
My Directory structure is as follows :
I have tried following code
import GetMyIp as getMyIP
import sys
sys.path.append("view/MainView")
import Server as server
import view.MainView