AttributeError: 'module' object has nohas attributee 'AddXY'

paramiko - _fastmath error in python: HAVE_DECL_MPZ_POWM_SEC - Stack Overflow
to customize your list.
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
J it only takes a minute:
Join the Stack Overflow community to:
Ask programming questions
Answer and help your peers
Get recognized for your expertise
I am running python 2.6 on Red Hat 6.4
I had a script running on one machine using paramiko sftp. When I transferred it to another machine I got an exception: SFTP file has no attribute __exit__ (something along those lines).
I decided to upgrade paramiko (thought it would solve the problem) with pip. Now I am getting this the moment I run a python script:
File "/usr/lib/python2.6/site-packages/paramiko/__init__.py", line 64, in &module&
from transport import SecurityOptions, Transport
File "/usr/lib/python2.6/site-packages/paramiko/transport.py", line 33, in &module&
from paramiko import util
File "/usr/lib/python2.6/site-packages/paramiko/util.py", line 33, in &module&
mon import *
File "/usr/lib/python2.6/site-packages/paramiko/common.py", line 98, in &module&
from Crypto import Random
File "/usr/lib64/python2.6/site-packages/Crypto/Random/__init__.py", line 29, in &module&
from Crypto.Random import _UserFriendlyRNG
File "/usr/lib64/python2.6/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 38, in &module&
from Crypto.Random.Fortuna import FortunaAccumulator
File "/usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaAccumulator.py", line 39, in &module&
import FortunaGenerator
File "/usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaGenerator.py", line 34, in &module&
from Crypto.Util.number import ceil_shift, exact_log2, exact_div
File "/usr/lib64/python2.6/site-packages/Crypto/Util/number.py", line 56, in &module&
if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC:
AttributeError: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'
It seems you have a mix of PyCrypto libraries installed in your system.
on the PyCrypto trackiong system seems related:
My guess is that you have the python-crypto-2.0.1 RPM installed system-wide,
and you didn't have gmp-devel installed when you built & installed a later
version of PyCrypto, so you'reusing a newer version of PyCrypto with an
older version of _fastmath.
You may try to do as suggested: install the gmp-devel package and then PyCrypto with pip.
For me, the issue was that I had the python-crypto package installed via yum, and then had also installed the pycrypto module via pip.
yum remove python-crypto
worked for me.
gives better insight into the error itself.
Some developer thought it a good idea to provide a user-friendly warning about a potential security threat, but botched up the code that prints that warning.
I just replaced this:
# You need libgmp v5 or later to get mpz_powm_sec.
Warn if it's not available.
if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC:
_warn("Not using mpz_powm_sec.
You should rebuild using libgmp &= 5 to avoid timing attack vulnerability.", PowmInsecureWarning)
with this:
# You need libgmp v5 or later to get mpz_powm_sec.
Warn if it's not available.
if _fastmath is not None and not hasattr(_fastmath, 'HAVE_DECL_MPZ_POWM_SEC'):
_warn("Not using mpz_powm_sec.
You should rebuild using libgmp &= 5 to avoid timing attack vulnerability.", PowmInsecureWarning)
in my /usr/lib64/python2.6/site-packages/Crypto/Util/number.py
It still can be done better, but if you don't care for the security threat, this will get you going.
3,90232139
If (like me) you don't have access to number.py, the following may help:
import Crypto.PublicKey._fastmath
Crypto.PublicKey._fastmath.HAVE_DECL_MPZ_POWM_SEC=False
add before to ignore the warning:
import warnings
from Crypto.pct_warnings import PowmInsecureWarning
warnings.simplefilter("ignore", PowmInsecureWarning)
you can find file: /usr/lib/python2.7/site-packages/Crypto/Util/number.py
with content:
if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC:
Then, you can annotate this line like
#if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC:
and you can import paramiko
13.8k103154
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabledPython AttributeError: Object has no attribute - Stack Overflow
to customize your list.
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
J it only takes a minute:
Join the Stack Overflow community to:
Ask programming questions
Answer and help your peers
Get recognized for your expertise
I have a class MyThread. In that I have a method sample. I am trying to run it from withing the same object context. Please have a look at the code:
class myThread (threading.Thread):
def __init__(self, threadID, name, counter, redisOpsObj):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
self.counter = counter
self.redisOpsObj = redisOpsObj
def stop(self):
self.kill_received = True
def sample(self):
print "Hello"
def run(self):
time.sleep(0.1)
print "\n Starting " + self.name
self.sample()
Looks very simple ain't it. But when I run it I get this error
AttributeError: 'myThread' object has no attribute 'sample' Now I have that method, right there. So what's wrong? Please help
Edit: This is the stacktrace
Starting Thread-0
Starting Thread-1
Exception in thread Thread-0:
Traceback (most recent call last):
File "/usr/lib/python2.6/threading.py", line 525, in __bootstrap_inner
self.run()
File "./redisQueueProcessor.py", line 51, in run
self.sample()
AttributeError: 'myThread' object has no attribute 'sample'
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.6/threading.py", line 525, in __bootstrap_inner
self.run()
File "./redisQueueProcessor.py", line 51, in run
self.sample()
AttributeError: 'myThread' object has no attribute 'sample'
I am calling it like this
arThreads = []
maxThreads = 2;
for i in range( maxThreads ):
redisOpsObj = redisOps()
arThreads.append( myThread(i, "Thread-"+str(i), 10, redisOpsObj) )
Sorry I can't post redisOps class code. But I can assure you that it works just fine
1,961143572
Your indentation is goofed, and you've mixed tabs and spaces. Run the script with python -tt to verify.
421k57743908
These kind of bugs are common when Python multi-threading. What happens is that, on interpreter tear-down, the relevant module (myThread in this case) goes through a sort-of del myThread.
The call self.sample() is roughly equivalent to myThread.__dict__["sample"](self).
But if we're during the interpreter's tear-down sequence, then its own dictionary of known types might've already had myThread deleted, and now it's basically a NoneType - and has no 'sample' attribute.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled异常信息:'Cursor'object has no attribute '_last_executed'异常出处:cursor.execute(&SELECT * FROM Stu WHERE name LIKE '%%s%'& % stu_name)原因:在python中,“%”是一个特殊字符,需要两个“%%”才表示一个“%”解决方法:用&%%&来表示一个百分号;在Django中如果还继续报错,那就再加上两个“%%%%”,三个是不可以的,一般都是2的倍数个百分号eg:cursor.execute(&SELECT * FROM Stu WHERE name LIKE '%%%%%s%%%%'& % stu_name)
无相关信息为什么会提示‘file’object has no attribute readLines'_百度知道
为什么会提示‘file’object has no attribute readLines'
提问者采纳
只有执行到那一步,不像Java有一套统一的规范,请继续追问,开发的时候可以多看看文档,有不确定的dir一下:  Python是解释执行的,我来为您解答,变量没有定义等等。另外,运行的时候是不会报错的,才会报错,比如没有这个方法。  如果我的回答没能帮助您,Python自带的标准库中代码风格各异,还有就是开个shell  您好,只要你写的代码没有语法问题
其他类似问题
为您推荐:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁}

我要回帖

更多关于 hasattribute 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信