Python Cryptography Error cannot import name certificate_transparency - python

trying to run a pymodbus tcp server and im getting this stack trace... at a total loss here so any help is appreciated. Thanks!
Traceback (most recent call last):
File "Worrking_ModbusJ1939Bridge.py", line 12, in <module>
from pymodbus.server.async import StartTcpServer
File "build/bdist.linux-armv7l/egg/pymodbus/server/async.py", line 18, in <module>
File "build/bdist.linux-armv7l/egg/pymodbus/internal/ptwisted.py", line 5, in <module>
File "/usr/local/lib/python2.7/dist-packages/twisted/conch/manhole_ssh.py", line 14, in <module>
from twisted.conch.ssh import factory, session
File "/usr/local/lib/python2.7/dist-packages/twisted/conch/ssh/factory.py", line 18, in <module>
from twisted.conch.ssh import (_kex, transport, userauth, connection)
File "/usr/local/lib/python2.7/dist packages/twisted/conch/ssh/transport.py", line 345, in <module>
class SSHTransportBase(protocol.Protocol):
File "/usr/local/lib/python2.7/dist-packages/twisted/conch/ssh/transport.py", line 469, in SSHTransportBase
supportedCiphers = _getSupportedCiphers()
File "/usr/local/lib/python2.7/dist-packages/twisted/conch/ssh/transport.py", line 335, in _getSupportedCiphers
backend=default_backend(),
File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/backends/__init__.py", line 15, in default_backend
from cryptography.hazmat.backends.openssl.backend import backend
File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/backends/openssl/__init__.py", line 7, in <module>
from cryptography.hazmat.backends.openssl.backend import backend
File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/backends/openssl/backend.py", line 16, in <module>
from cryptography import utils, x509
File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/__init__.py", line 7, in <module>
from cryptography.x509 import certificate_transparency
ImportError: cannot import name certificate_transparency

I was using pip 7 and got the same problem. Upgrading to pip 9 solved it. I'm not sure about the cause.
Via: https://github.com/micheloosterhof/cowrie/issues/618

I've been hitting this while attempting to update Python Cryptography for Solaris 11.4, using the https://github.com/oracle/solaris-userland/ build system. A "simple" update to pip isn't an option for me, that's not how we do things.
I eventually figured out the solution: I'd built the package incorrectly.
Cryptography 2.1.4 depends on cffi > 1.7. Both of these packages have new deliverable bits compared to the versions we were shipping.
Failing to update the package manifest to correctly track the new files results in both cffi and cryptography being unable to import symbols that the current versions depend upon.
[A very big thankyou to Alex Gaynor in #cryptography-dev who set me on the right path to figuring this out].
$ python2.7
Python 2.7.14 (default, Jan 31 2018, 05:35:05) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> from cryptography.hazmat.bindings._openssl import ffi, lib
>>> from cryptography.x509 import certificate_transparency
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/vendor-packages/cryptography/x509/__init__.py", line 7, in <module>
from cryptography.x509 import certificate_transparency
ImportError: cannot import name certificate_transparency
If you build cryptography and look at what it delivers, you will find that there is in fact a file (shipped on Solaris as /usr/lib/python-$(PYVER)/vendor-packages/cryptography/x509/certificate_transparency.py) - and if that file isn't in the rest of the hierarchy then you end up with exactly this ImportError.

it works for me (problems with paramiko):
https://pypi.python.org/pypi/ctutlz/0.7.0
pip install --process-dependency-links ctutlz

I had a similar issue on RHEL 6.7 x86_64 running Python 2.7.8 with an old version of pip (1.4.1)
It was because I had been installing the "cp27m" builds rather than "cp27mu" builds.
With the old pip 1.4.1 build, it did not complain installing the cp27m builds.
Whereas when upgrading pip to 9.0.3, it spat out the true error ...
(bmcs2)bash-4.1$ pip install cffi-1.11.5-cp27-cp27m-manylinux1_x86_64.whl
cffi-1.11.5-cp27-cp27m-manylinux1_x86_64.whl is not a supported wheel on this platform.
(bmcs2)bash-4.1$ pip install cryptography-2.1.3-cp27-cp27m-manylinux1_x86_64.whl
cryptography-2.1.3-cp27-cp27m-manylinux1_x86_64.whl is not a supported wheel on this platform.
The "ImportError: cannot import name certificate_transparency" was resolved using the "cp27mu" builds. When using the "cp27mu" build, both the pip 1.4.1 and pip 9.0.3 versions worked fine.
cffi-1.11.5-cp27-cp27m-manylinux1_x86_64.whl versus cffi-1.11.5-cp27-cp27mu-manylinux1_x86_64.whl
cryptography-2.1.3-cp27-cp27m-manylinux1_x86_64.whl versus cryptography-2.1.3-cp27-cp27mu-manylinux1_i686.whl
More info here:
https://www.python.org/dev/peps/pep-0513/#ucs-2-vs-ucs-4-builds

I think this more like a paramiko issue not pip. Upgrading pip didn't solve this in my environment i had to downgrade my paramiko version to a version that does not have a libffi dependency, this worked for me:
pip2.7 install paramiko==1.17.0
this issue is related to: https://github.com/paramiko/paramiko/issues/1401

I got this error while trying to run Scrapy in AWS Lambda, deploying with a zip file.
I followed the instructions in https://www.perrygeo.com/running-python-with-compiled-code-on-aws-lambda.html, which basically instructs you to start an Amazon Linux EC2 instance, install the requirements and build the zip from it.
After setting up the whole thing, the first package I created still gave me the same error, but I realised that was because a hidden folder, .libs_cffi_backend, was missing from the zip file. That folder contains a .so file that if not present causes ImportError. After forcefully including it, it worked.

Related

Import NumPy gives me ImportError: DDL load failed: The specified procedure could not be found?

My Environment: Win10 64 bits, Python 3.6 and I use pip install to install NumPy instead of Anaconda. NumPy version: 1.13.0
I have seen several people posted similar questions, but most of them are using Python 2.7. The closest solution I have seen so far is: https://github.com/ContinuumIO/anaconda-issues/issues/1508 and https://github.com/numpy/numpy/issues/9272. But it seems they did not solve it in the end and the people who posted it are using Python 2.7. Therefore, I was wondering if someone can help me about this. My error log is below. Any help would be appreciated.
C:\Users\Kevin>python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "D:\Python3.6\lib\site-packages\numpy\core\__init__.py", line 16, in
<module>
from . import multiarray
ImportError: DLL load failed: The specified procedure could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Python3.6\lib\site-packages\numpy\__init__.py", line 142, in
<module>
from . import add_newdocs
File "D:\Python3.6\lib\site-packages\numpy\add_newdocs.py", line 13, in
<module>
from numpy.lib import add_newdoc
File "D:\Python3.6\lib\site-packages\numpy\lib\__init__.py", line 8, in
<module>
from .type_check import *
File "D:\Python3.6\lib\site-packages\numpy\lib\type_check.py", line 11, in
<module>
import numpy.core.numeric as _nx
File "D:\Python3.6\lib\site-packages\numpy\core\__init__.py", line 26, in
<module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: DLL load failed: The specified procedure could not be
found.
You should go with doing a clean install of numpy. Just don't go with the traditional way but download the wheel file instead. You can get the wheel file from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/ . Download this file- numpy‑1.13.0+mkl‑cp36‑cp36m‑win_amd64.whl and install this wheel using pip. Check by importing numpy from shell.
If you do not want to bother with finding the wheel file just uninstall numpy and install an old version:
pip3 uninstall numpy
pip3 install 'numpy<1.13'
Uninstall NumPy and after that type:
pip3 install numpy==1.12

ImportError: No module named _bsddb

I had some problems with upgrading matplotlib recently so I ended up installing different versions of Python on my Mac (Sierra) via brew, and then uninstalled afterwards. However, now matplotlib works (2.0.2) but whenever I run a particular python script that used to work I get an error which I didn't have before:
Traceback (most recent call last):
File "sim.py", line 254, in <module>
main()
File "sim.py", line 118, in main
db = shelve.open('.sim_balance', 'c')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shelve.py", line 243, in open
return DbfilenameShelf(filename, flag, protocol, writeback)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shelve.py", line 227, in __init__
Shelf.__init__(self, anydbm.open(filename, flag), protocol, writeback)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/anydbm.py", line 84, in open
mod = __import__(result)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/dbhash.py", line 7, in <module>
import bsddb
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/bsddb/__init__.py", line 67, in <module>
import _bsddb
ImportError: No module named _bsddb
According to my searches online this has something to do with my brew installed python interfering? I also deleted all my files in /Library/Python/2.7/site-packages yesterday which may have caused this as well.
I have tried homebrew brew install berkeley-db but then pip install bsddb3 yields:
Terrys-MBP:site-packages Terry$ pip install bsddb3
Collecting bsddb3
Using cached bsddb3-6.2.4.tar.gz
Complete output from command python setup.py egg_info:
Can't find a local Berkeley DB installation.
(suggestion: try the --berkeley-db=/path/to/bsddb option)
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/m5/1fg5rnj11_9cz5pntlqlwzyc0000gn/T/pip-build-elBAFK/bsddb3/
EDIT: Solved. Installed anaconda, installed bsddb via conda install and everything is working now.
Solved. I Installed anaconda, installed bsddb via conda install and everything is working now.

Theano import error: No module named cPickle

>>> import theano
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/theano/__init__.py", line 52, in <module>
from theano.gof import (
File "/Library/Python/2.7/site-packages/theano/gof/__init__.py", line 38, in <module>
from theano.gof.cc import \
File "/Library/Python/2.7/site-packages/theano/gof/cc.py", line 30, in <module>
from theano.gof import link
File "/Library/Python/2.7/site-packages/theano/gof/link.py", line 18, in <module>
from theano.gof.type import Type
File "/Library/Python/2.7/site-packages/theano/gof/type.py", line 17, in <module>
from theano.gof.op import CLinkerObject
File "/Library/Python/2.7/site-packages/theano/gof/op.py", line 25, in <module>
from theano.gof.cmodule import GCC_compiler
File "/Library/Python/2.7/site-packages/theano/gof/cmodule.py", line 8, in <module>
import six.moves.cPickle as pickle
ImportError: No module named cPickle
I'm pretty sure there is no problem with cPickle. Can it be the problem of other dependencies? It's true that I upgraded all the packages this morning, so that a conflict of version may occur. Nonetheless, the problem still exists after I switched to the bleeding-edge version of theano. Would someone help me figure it out?
PS: My developing device is Macbook Pro 13(early 2015); my system version is OS X 10.10.5; python version is 2.7.10
=========================== Second Edit ===================================
It seems I do have latest version of six installed on my Mac.
YiqundeMacBook-Pro:~ Leo$ pip show six
---
Metadata-Version: 2.0
Name: six
Version: 1.9.0
Summary: Python 2 and 3 compatibility utilities
Home-page: http://pypi.python.org/pypi/six/
Author: Benjamin Peterson
Author-email: benjamin#python.org
License: MIT
Location: /Library/Python/2.7/site-packages
Requires:
I had the same problem and upgrading six solved issue:
sudo easy_install --upgrade six
Try to avoid using sudo at all costs. Open a python session and run
import six
print six.__version__
print six.__file__
The version will likely not be most recent (1.10.0), so go manually delete the six.py and six.pyc files at the imported path, and then run pip install six. Python should now be importing the latest version of six, compatible with Theano :)

Plotly killed my python install

I just tried to install Plotly using pip. I am running python from Anaconda and now anytime I attempt to run anything python I get the following errors and I have no idea how to fix it. I am running on Windows 7 64bit, Python3,4
PS Z:\> pip
Traceback (most recent call last):
File "C:\Anaconda3\Scripts\pip-script.py", line 3, in <module>
from pip import main
File "C:\Anaconda3\lib\site-packages\pip\__init__.py", line 11, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "C:\Anaconda3\lib\site-packages\pip\vcs\mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "C:\Anaconda3\lib\site-packages\pip\download.py", line 22, in <module>
from pip._vendor import requests, six
File "C:\Anaconda3\lib\site-packages\pip\_vendor\requests\__init__.py", line 58, in <module>
from . import utils
File "C:\Anaconda3\lib\site-packages\pip\_vendor\requests\utils.py", line 25, in <module>
from .compat import parse_http_list as _parse_list_header
File "C:\Anaconda3\lib\site-packages\pip\_vendor\requests\compat.py", line 77, in <module>
import simplejson as json
File "C:\Anaconda3\lib\site-packages\simplejson\__init__.py", line 112, in <module>
from .scanner import JSONDecodeError
File "C:\Anaconda3\lib\site-packages\simplejson\scanner.py", line 10, in <module>
c_make_scanner = _import_c_make_scanner()
File "C:\Anaconda3\lib\site-packages\simplejson\scanner.py", line 6, in _import_c_make_scanner
from simplejson._speedups import make_scanner
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 4: invalid start byte
PS Z:\>
This is an interaction between Anaconda's version of pip and the latest version of simplejson (which was installed when you installed Plotly).
As a workaround,
del C:\Anaconda3\lib\site-packages\simplejson
This will allow pip and Plotly to work again. Unfortunately if you ever upgrade Plotly this problem will happen again, so we will add a workaround to the Plotly requirements.txt file that prevents this from happening in future. (Plotly only actually needs simplejson on Python 2.6 systems.)
There was an Anaconda issue open related to this that I've commented on: https://github.com/ContinuumIO/anaconda-issues/issues/238
Plotly Python API issue re: finding a workaround so this doesn't happen again (or to other users): https://github.com/plotly/python-api/issues/197
As of version 1.6.10 for the plotly package, the simplejson and ordereddict packages are no longer dependencies.
TL;DR:
Python 2.6 should use:
pip install plotly[PY2.6]
While Python 2.7, 3.3, and 3.4 should still use:
pip install plotly
More Info:
If you're already hitting the issue in this post, you'll likely need to remove the simplejson package as discussed in answer scjody gave.
The simplejson and ordereddict packages were there to have common dependencies for Python 2.6 through Python 3.4. However, since simplejson clashes with anaconda, we now have an "extras" option for the pip install.
As usual, because the version of IPython we depend on doesn't support Python 2.6, there are still two optional requirements files which install matplotlib, IPython[notebook], etc.
optional_requirements.txt
optional_requirements-2-6.txt
Quotes Notes:
Depending on the shell you're using, you may need to wrap the install target in quotes ('') when using the extras for Python 2.6:
pip install 'plotly[PY2.6]'

ImportError: DLL load failed: %1 is not a valid Win32 application - paramiko

I have a situation in win7 64bit, after I installing paramiko 1.12.1 by using easy_install paramiko,I'm using 64bit python2.7 , also installed 64bit pycrypto, there is a import error:
>>> import paramiko
enter code hereenter code hereTraceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import paramiko
File "build\bdist.win-amd64\egg\paramiko\__init__.py", line 65, in <module>
File "build\bdist.win-amd64\egg\paramiko\transport.py", line 33, in <module>
File "build\bdist.win-amd64\egg\paramiko\util.py", line 33, in <module>
File "build\bdist.win-amd64\egg\paramiko\common.py", line 98, in <module>
File "c:\users\yapan\appdata\local\temp\easy_install-6upp3i\pycrypto-2.6-py2.7-win-amd64.egg.tmp\Crypto\Random\__init__.py", line 28, in <module>
File "c:\users\yapan\appdata\local\temp\easy_install-6upp3i\pycrypto-2.6-py2.7-win-amd64.egg.tmp\Crypto\Random\OSRNG\__init__.py", line 34, in <module>
File "c:\users\yapan\appdata\local\temp\easy_install-6upp3i\pycrypto-2.6-py2.7-win-amd64.egg.tmp\Crypto\Random\OSRNG\nt.py", line 28, in <module>
File "c:\users\yapan\appdata\local\temp\easy_install-6upp3i\pycrypto-2.6-py2.7-win-amd64.egg.tmp\Crypto\Random\OSRNG\winrandom.py", line 7, in <module>
File "c:\users\yapan\appdata\local\temp\easy_install-6upp3i\pycrypto-2.6-py2.7-win-amd64.egg.tmp\Crypto\Random\OSRNG\winrandom.py", line 6, in __bootstrap__
ImportError: DLL load failed: %1 is not a valid Win32 application.
Any thoughs?
This is a problem I ran into as well. I have Windows Server 2012 64 bit and python 32 bit. What I ended up doing is letting pip solve everything.
I have pip 1.6.dev1.
pip install --upgrade paramiko
*if you get this error during upgrade:
AttributeError: 'str' object has no attribute 'rollback', do:
pip uninstall pycrypto and enter (y)
pip install pycrypto
pip install ecdsa
Basically, just try to run that first command, and follow the tracebacks to resolve whatever dependency is missing. This worked for me.
I saved my session in txt if you need it for reference.
-Daniel
If you are having trouble building and installing Python 2.7 components that depend on compiled C modules, I highly recommend you check out Microsoft's specially packaged compiler for Python 2.7, here:
http://www.microsoft.com/en-us/download/confirmation.aspx?id=44266
I had ALL kinds of trouble getting pycrypto to install on Windows 7 64-bit (I was trying to get Fabric to work, which depends on paramiko which depends on pycrypto). After installing the aforementioned compiler and then doing:
pip install wheel
pip uninstall pycrypto paramiko
pip install paramiko
Everything just started working! Hope that helps anyone landing on this answer from Google in the future.

Categories