Importing pysftp issue - python

I am facing this error every time I try to import pysftp in my training.py in the ml.azure.com pipelines. I am using Conda to create the environment for the workspace.
Traceback (most recent call last):
File "start_training.py", line 18, in <module>
import pysftp
File "/azureml-envs/azureml_8b4da5162aa2d3fe6990b8afc7945879/lib/python3.7/site-packages/pysftp/__init__.py", line 12, in <module>
import paramiko
File "/azureml-envs/azureml_8b4da5162aa2d3fe6990b8afc7945879/lib/python3.7/site-packages/paramiko/__init__.py", line 22, in <module>
from paramiko.transport import SecurityOptions, Transport
File "/azureml-envs/azureml_8b4da5162aa2d3fe6990b8afc7945879/lib/python3.7/site-packages/paramiko/transport.py", line 89, in <module>
from paramiko.dsskey import DSSKey
File "/azureml-envs/azureml_8b4da5162aa2d3fe6990b8afc7945879/lib/python3.7/site-packages/paramiko/dsskey.py", line 37, in <module>
from paramiko.pkey import PKey
File "/azureml-envs/azureml_8b4da5162aa2d3fe6990b8afc7945879/lib/python3.7/site-packages/paramiko/pkey.py", line 31, in <module>
import bcrypt
File "/azureml-envs/azureml_8b4da5162aa2d3fe6990b8afc7945879/lib/python3.7/site-packages/bcrypt/__init__.py", line 25, in <module>
from . import _bcrypt # type: ignore
ImportError: libffi.so.7: cannot open shared object file: No such file or directory
What I tried and failed:
I also tried to import the older version of pysftp which doesn't have dependency on libffi.so,
I tried with several versions of pysftp.
I tried installing the dependencies of pysftp.
I tried installing paramiko separately with current and older version.
I tried installing the bcrypt with current and older version.
I tried installing libffi.so with current and older version.
I tried creating new environments.
I tried by updating conda and pip also.
I tried to create simlink between libffi.so.6 and libffi.so.7 also.
So far, nothing works.
Help needed on this.

Related

'google.protobuf.descriptor' has no attribute '_internal_create_key'

I get the following error when trying to import simpletransformers:
Traceback (most recent call last):
File "...py", line 106, in <module>
from simpletransformers.classification import ClassificationModel, ClassificationArgs
File "/home/work/anaconda/lib/python3.6/site-packages/simpletransformers/classification/__init__.py", line 1, in <module>
from simpletransformers.classification.classification_model import ClassificationModel
File "/home/work/anaconda/lib/python3.6/site-packages/simpletransformers/classification/classification_model.py", line 32, in <module>
from tensorboardX import SummaryWriter
File "/home/work/anaconda/lib/python3.6/site-packages/tensorboardX/__init__.py", line 4, in <module>
from .record_writer import RecordWriter
File "/home/work/anaconda/lib/python3.6/site-packages/tensorboardX/record_writer.py", line 18, in <module>
from google.cloud import storage
File "/home/work/anaconda/lib/python3.6/site-packages/google/cloud/storage/__init__.py", line 38, in <module>
from google.cloud.storage.batch import Batch
File "/home/work/anaconda/lib/python3.6/site-packages/google/cloud/storage/batch.py", line 29, in <module>
from google.cloud import _helpers
File "/home/work/anaconda/lib/python3.6/site-packages/google/cloud/_helpers.py", line 33, in <module>
from google.protobuf import duration_pb2
File "/home/work/anaconda/lib/python3.6/site-packages/google/protobuf/duration_pb2.py", line 21, in <module>
create_key=_descriptor._internal_create_key,
AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key'
I already tried upgrading protobuf and have same protoc version like in this question:
How to solve "AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key"?
I also tried upgrading other packages. What else could be the problem?
I am having the issue on cloud linux machine. On my local windows machine, there is no problem.
The protoc version I got through pip show protobuf and protoc --version were different. The version in pip was a bit outdated.
After I upgraded the pip version with
pip install --upgrade protobuf
the problem was solved.
If python3, use pip3 install --upgrade protobuf
I encountered the same issue of protobuf version is equal to protoc and error still exist. But after rebooting my computer, It's work.

cryptography.hazmat.bindings._openssl import ffi, lib ImportError: DLL load failed:

Getting the following error on Win10 when trying to connect spyder to the remote kernel:
Traceback (most recent call last):
File "C:\Users\a010735\AppData\Local\Continuum\anaconda3\lib\site-packages\paramiko\transport.py", line 2010, in run
self._handler_table[ptype](self, m)
File "C:\Users\a010735\AppData\Local\Continuum\anaconda3\lib\site-packages\paramiko\transport.py", line 2126, in _negotiate_keys
self.kex_engine.start_kex()
File "C:\Users\a010735\AppData\Local\Continuum\anaconda3\lib\site-packages\paramiko\kex_ecdh_nist.py", line 32, in start_kex
self._generate_key_pair()
File "C:\Users\a010735\AppData\Local\Continuum\anaconda3\lib\site-packages\paramiko\kex_ecdh_nist.py", line 53, in _generate_key_pair
self.P = ec.generate_private_key(self.curve, default_backend())
File "C:\Users\a010735\AppData\Local\Continuum\anaconda3\lib\site-packages\cryptography\hazmat\backends\__init__.py", line 15, in default_backend
from cryptography.hazmat.backends.openssl.backend import backend
File "C:\Users\a010735\AppData\Local\Continuum\anaconda3\lib\site-packages\cryptography\hazmat\backends\openssl\__init__.py", line 7, in <module>
from cryptography.hazmat.backends.openssl.backend import backend
File "C:\Users\a010735\AppData\Local\Continuum\anaconda3\lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 62, in <module>
from cryptography.hazmat.bindings.openssl import binding
File "C:\Users\a010735\AppData\Local\Continuum\anaconda3\lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 14, in <module>
from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: DLL load failed: The specified procedure could not be found.
*** Failed to connect to 10.144.20.72:22: ImportError('DLL load failed: The specified procedure could not be found.')
Since I had the same issue I'm doing some Necromancy on this question:
My Solution is more of a workaround then anything else. I assume you are using anaconda since you mention spyder. My problem seems to have arisen form using pip to install pysftp into the anaconda environment. I had to uninstall anaconda, revert to my original python environment and there it worked without any problems.
Since I like spyder I installed it via pip into that environment...works so far

"No module named zlib" error anytime I use pip

I'm using terminal on mac, and anytime I attempt to use pip, I get the following error message telling me that it cannot find a module named zlib:
$ pip --version
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/__init__.py", line 27, in <module>
from . import urllib3
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 42, in <module>
from .response import HTTPResponse
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 3, in <module>
import zlib
ModuleNotFoundError: No module named 'zlib'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/bin/pip", line 7, in <module>
from pip import main
File "/usr/local/lib/python3.6/site-packages/pip/__init__.py", line 21, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/__init__.py", line 62, in <module>
from .packages.urllib3.exceptions import DependencyWarning
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/__init__.py", line 29, in <module>
import urllib3
File "/usr/local/lib/python3.6/site-packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 36, in <module>
from .response import HTTPResponse
File "/usr/local/lib/python3.6/site-packages/urllib3/response.py", line 3, in <module>
import zlib
ModuleNotFoundError: No module named 'zlib'
I've read several SO posts with the same error message, and have tried their solutions, including attempting to install zlib using homebrew, which fails, and updating my Xcode developer tools. I also installed pip earlier using python get-pip.py, and it said it installed successfully.
The reason I need pip is to install a package for use on python 2.7, but doing $ pip install "package-name" produces the same error as above. I have both Python 2 and 3 installed on my machine, if that helps. I'm kind of new to pip and using the command line in general, and I'm super confused; if anyone could help me out I'd really appreciate it.
This is the OP. I was able to fix the issue, and wanted to post my solution here in case it would help others.
Essentially I believe it occurred because Python2 is default on my machine, but pip is by default pointing to resources pertaining to Python3, or something like that. Doing pip2 --version instead provided the expected response.

pip commands return a TypeError

I needed to install hashlib for one of my projects, and used easy_install hashlib (as was stated by this Stack Exchange post) to do so. However, right after I installed this package, I haven't been able to use pip at all. Whenever I type a command with pip (like pip install), I get the following error message:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 37, in <module>
import email.parser
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/parser.py", line 12, in <module>
from email.feedparser import FeedParser
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/feedparser.py", line 27, in <module>
from email import message
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/message.py", line 16, in <module>
import email.charset
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/charset.py", line 13, in <module>
import email.base64mime
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/base64mime.py", line 40, in <module>
from email.utils import fix_eols
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/utils.py", line 27, in <module>
import random
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py", line 49, in <module>
import hashlib as _hashlib
File "build/bdist.macosx-10.13-intel/egg/hashlib.py", line 115, in <module>
"""
TypeError: 'frozenset' object is not callable
This also now occurs when I'm using easy_install- same error. I'm also not able to uninstall pip and reinstall- any command with pip results in the error above. Even executing
pip --version yields the same error. I know it's something to do with the hashlib package, but I'm not sure how to delete it and reinstall without messing up my entire Python configurations. My hypothesis is that the version of hashlib I installed is either too old or too new for my Python 2.7, and doesn't play well with it.
Does anyone know what exactly is going on behind the scenes here in this stack trace, and how I can fix pip?
Is the best thing to do to literally go in and delete hashlib.py from my lib/python2.7 folder?
So, this doesn't solve the issue with hashlib, but it does get you a working pip again: literally download and reinstall Python 2.7 all over again from the source. If anyone comes up with a better, more elegant solution for fixing pip, I am all for it.
However, at least I can use pip again...

ubuntu ImportError: cannot import name MAXREPEAT

Upgrade to 13.04 has totally messed my system up .
I am having this issue when running
./manage.py runserver
Traceback (most recent call last):
File "./manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
File "/home/rats/rats/local/lib/python2.7/site-packages/django/core/management
/__init__.py", line 4, in <module>
from optparse import OptionParser, NO_DEFAULT
File "/usr/lib/python2.7/optparse.py", line 77, in <module>
import textwrap
File "/usr/lib/python2.7/textwrap.py", line 10, in <module>
import string, re
File "/usr/lib/python2.7/string.py", line 83, in <module>
import re as _re
File "/home/rats/rats/lib/python2.7/re.py", line 105, in <module>
import sre_compile
File "/home/rats/rats/lib/python2.7/sre_compile.py", line 14, in <module>
import sre_parse
File "/home/rats/rats/lib/python2.7/sre_parse.py", line 17, in <module>
from sre_constants import *
File "/home/rats/rats/lib/python2.7/sre_constants.py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
this is happening for both the real environment as well as for virtual environment .
i tried removing python with
sudo apt-get remove python
and sadly it has removed everything .
now google chrome does not show any fonts .
i am looking for getting things back to work .
help is needed for proper configuring it again.
If you are using virtualenvwrapper then you can recreate the virtualenv on top of the existing one (with no environment currently active):
mkvirtualenv <existing name>
which should pull in the latest (upgraded) python version from the system and fix any mismatch errors.
You don't need to recreate the environment.
You can upgrade the virtualenv running this command:
virtualenv /PATH/TO/YOUR_OLD_ENV
YOUR_OLD_ENV folder will be properly upgraded to the version 2.7.4.
I have just solved that problem on my machine.
The problem was that Ubuntu 13.04 use python 2.7.4. That makes conflict with the Python version of the virtualenv.
What I do was to re-create the virtualenv with the new version of python. I think it's the simplest way, but you can try to upgrade the python version without re-creating all of the virtualenv.

Categories

Resources