when importing ethjsonrpc It throws an error as below:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/ethjsonrpc/__init__.py", line 1, in <module>
from ethjsonrpc.client import (EthJsonRpc, ParityEthJsonRpc,
File "/usr/local/lib/python3.6/site-packages/ethjsonrpc/client.py", line 7, in <module>
from ethereum import utils
File "/usr/local/lib/python3.6/site-packages/ethereum/utils.py", line 103, in <module>
assert sha3('').encode('hex') == 'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
AttributeError: 'bytes' object has no attribute 'encode'
This is an issue with ethjsonrpc as can be seen on the github issue page. The proposed fix is to just comment the line 103 in /usr/local/lib/python3.6/site-packages/ethereum/utils.py
Might be a good idea to switch to using this module with python2 instead in case more errors appear that are caused by version differences.
Related
my project can't make import idk why
the error is showing
seifahmed15#Ubuntu:~/Desktop/DAC-master$ python3 main.py
Traceback (most recent call last):
File "/home/seifahmed15/Desktop/DAC-master/main.py", line 2, in <module>
from user import create
File "/home/seifahmed15/Desktop/DAC-master/user.py", line 5, in <module>
import hcaptcha
File "/home/seifahmed15/Desktop/DAC-master/hcaptcha.py", line 6, in <module>
from seleniumwire.undetected_chromedriver import Chrome
File "/home/seifahmed15/.local/lib/python3.11/site-packages/seleniumwire/undetected_chromedriver/__init__.py", line 9, in <module>
from seleniumwire.webdriver import Chrome
File "/home/seifahmed15/.local/lib/python3.11/site-packages/seleniumwire/webdriver.py", line 13, in <module>
from seleniumwire import backend
File "/home/seifahmed15/.local/lib/python3.11/site-packages/seleniumwire/backend.py", line 4, in <module>
from seleniumwire.server import MitmProxy
File "/home/seifahmed15/.local/lib/python3.11/site-packages/seleniumwire/server.py", line 4, in <module>
from seleniumwire.handler import InterceptRequestHandler
File "/home/seifahmed15/.local/lib/python3.11/site-packages/seleniumwire/handler.py", line 5, in <module>
from seleniumwire import har
File "/home/seifahmed15/.local/lib/python3.11/site-packages/seleniumwire/har.py", line 11, in <module>
from seleniumwire.thirdparty.mitmproxy import connections
File "/home/seifahmed15/.local/lib/python3.11/site-packages/seleniumwire/thirdparty/mitmproxy/connections.py", line 9, in <module>
from seleniumwire.thirdparty.mitmproxy.net import tls, tcp
File "/home/seifahmed15/.local/lib/python3.11/site-packages/seleniumwire/thirdparty/mitmproxy/net/tls.py", line 43, in <module>
"SSLv2": (SSL.SSLv2_METHOD, BASIC_OPTIONS),
^^^^^^^^^^^^^^^^
AttributeError: module 'OpenSSL.SSL' has no attribute 'SSLv2_METHOD'. Did you mean: 'SSLv23_METHOD'?
i have reinstall python and tried to install pkg manually
i have searched on google and YouTube and i didn't find any thing
The console message below offers a bit more context on one issue, specifically on line 43:
File "/home/seifahmed15/.local/lib/python3.11/site-packages/seleniumwire/thirdparty/mitmproxy/net/tls.py", line 43, in <module>
"SSLv2": (SSL.SSLv2_METHOD, BASIC_OPTIONS),
^^^^^^^^^^^^^^^^
AttributeError: module 'OpenSSL.SSL' has no attribute 'SSLv2_METHOD'. Did you mean: 'SSLv23_METHOD'?
It looks like you may have a typo in the area below:
"SSLv2": (SSL.SSLv2_METHOD, BASIC_OPTIONS)
As the error message tells us:
'OpenSSL.SSL' has no attribute 'SSLv2_METHOD'. Did you mean: 'SSLv23_METHOD'?
You could try revising like below:
"SSLv2": (SSL.SSLv23_METHOD, BASIC_OPTIONS)
The other text in your console log appears to be showing the full stack trace - There may be an error elsewhere, but the error message you posted seems to be referencing that specific error on line 43.
The thread below may help a bit with handling the stack trace and debugging further:
Get exception description and stack trace which caused an exception, all as a string
I have installed the symbolic package. There are some python related errors in the command window of Octave when I try to use symbolic.Below is the output:
> pkg load symbolic
>> syms a
Symbolic pkg v2.9.0: Traceback (most recent call last):
File "<stdin>", line 28, in <module>
AttributeError: '_PrintFunction' object has no attribute '__globals__'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 12, in octoutput_drv
File "<stdin>", line 54, in octoutput
File "<stdin>", line 55, in octoutput
AttributeError: module 'sympy' has no attribute 'compatibility'
Closing the Python communications link.
error: Python exception: AttributeError: '_PrintFunction' object has no attribute '__globals__'
occurred in python_header import block.
Try "sympref reset" and repeat your command?
(consider filing an issue at https://github.com/cbm755/octsympy/issues)
error: called from
pycall_sympy__ at line 191 column 5
valid_sym_assumptions at line 38 column 10
assumptions at line 82 column 7
syms at line 97 column 13
>> Opening in existing browser session.
Any idea how i can troubleshoot this?
Thanks.
The error is a known bug (https://github.com/cbm755/octsympy/issues/1035)
You need to use an older version of sympy sunch as version 1.5.1
I'm having some issues running checkov, I'm not familiar with python libraries, anyone can give me some hints?
This is working fine in some machines but not in this one in particular...
Running in CentOS:
$ checkov --directory cdk.out
Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in <module>
from checkov.main import run
File "/usr/local/lib/python3.6/site-packages/checkov/main.py", line 22, in <module>
from checkov.terraform.plan_runner import Runner as tf_plan_runner
File "/usr/local/lib/python3.6/site-packages/checkov/terraform/plan_runner.py", line 11, in <module>
from checkov.terraform.context_parsers.registry import parser_registry
File "/usr/local/lib/python3.6/site-packages/checkov/terraform/context_parsers/__init__.py", line 1, in <module>
from checkov.terraform.context_parsers.parsers import *
File "/usr/local/lib/python3.6/site-packages/checkov/terraform/context_parsers/parsers/provider_context_parser.py", line 1, in <module>
import hcl2
File "/usr/local/lib/python3.6/site-packages/hcl2/__init__.py", line 5, in <module>
from .api import load, loads
File "/usr/local/lib/python3.6/site-packages/hcl2/api.py", line 4, in <module>
from hcl2.parser import hcl2
File "/usr/local/lib/python3.6/site-packages/hcl2/parser.py", line 53, in <module>
hcl2 = Lark_StandAlone(transformer=DictTransformer())
File "/usr/local/lib/python3.6/site-packages/hcl2/lark_parser.py", line 8, in Lark_StandAlone
return Lark._load_from_dict(DATA, MEMO, **kwargs)
AttributeError: type object 'Lark' has no attribute '_load_from_dict'
After upgrading python from 3.6 to 3.8 and reinstalling checkov it worked just fine.
When I write the following line of code
import urllib
I get this error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/urllib.py", line 26, in <module>
import socket
File "socket.py", line 2, in <module>
s = socket.socket()
TypeError: 'module' object is not callable
After going through various questions on SO I tried these:
from urllib import urlopen
(Same error as above)
>>> urllib
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'urllib' is not defined
>>> urllib.urlopen()
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'urllib' is not defined
Please help. I get a similar error when I try to import urllib2, urllib3, requests.
You named your file socket.py, hiding the standard library socket module. Name it something else.
I am new to python.And i am learning the standard library.
Whenever i run the code below , it always raise the AttributeError...
And it seems like there is something wrong with the import command.
Also , i try to run it on the interactive interpreator,and it works just fine.
The sample code
import tempfile
import os
#temp = tempfile.TemporaryFile()
temp = tempfile.mktemp()
print "tempfile","=>",temp
file = open(temp,"w+b")
file.write("*" * 1000)
file.seek(0)
print len(file.read()),"byte"
file.close()
try:
os.remove(temp)
except OSError:
pass
The error output
Traceback (most recent call last):
File "tempfile.py", line 1, in <module>
import tempfile
File "/home/zhkzyth/codeRep/pytest/tempfile.py", line 5, in <module>
tempfile = tempfile.mktemp()
AttributeError: 'module' object has no attribute 'mktemp'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 66, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python2.7/dist-packages/apport/__init__.py", line 1, in <module>
from apport.report import Report
File "/usr/lib/python2.7/dist-packages/apport/report.py", line 12, in <module>
import subprocess, tempfile, os.path, urllib, re, pwd, grp, os
File "/home/zhkzyth/codeRep/pytest/tempfile.py", line 5, in <module>
tempfile = tempfile.mktemp()
AttributeError: 'module' object has no attribute 'mktemp'
Original exception was:
Traceback (most recent call last):
File "tempfile.py", line 1, in <module>
import tempfile
File "/home/zhkzyth/codeRep/pytest/tempfile.py", line 5, in <module>
tempfile = tempfile.mktemp()
AttributeError: 'module' object has no attribute 'mktemp'
My enviroment
ubuntu12.04
python2.7
Did you name your own file tempfile.py? If so, rename it, delete all your *.pyc files, and try again.
PS: providing the actual text of the error with the traceback would tell us these things.
Trying to access an attribute that does not belong to a class or function in a module raises an AttributeError exception, the attribute might have been deprecated in a later version of the Python interpreter being used. I suggest you check the version of the Python you're running and make sure your dir(module) includes the attribute you're trying to use