Today I've run into problems trying to use the python-bitcoinlib in a small python program. It worked perfectly a few days ago but today the library seems to be broken (see console output below).
I'm in a Mac with OS X 11.0.1 (yes, I upgraded today, but I would be surprised if that's the cause of the problem).
I've tried several times installing and uninstalling the library and even python, but nothing seems to happen.
Thanks in advance.
>>> from bitcoin.rpc import RawProxy
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
from bitcoin.rpc import RawProxy
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/bitcoin/rpc.py", line 48, in <module>
from bitcoin.wallet import CBitcoinAddress, CBitcoinSecret
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/bitcoin/wallet.py", line 33, in <module>
import bitcoin.core.key
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/bitcoin/core/key.py", line 34, in <module>
_ssl = ctypes.cdll.LoadLibrary(ctypes.util.find_library('ssl') or 'libeay32')
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py", line 452, in LoadLibrary
return self._dlltype(name)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(libeay32, 6): image not found
My solution is not using RawProxy.
Impor this instead:
from bitcoinrpc.authproxy import AuthServiceProxy
And connect to bitcoin core with this sentence or equivalent:
p = AuthServiceProxy("http://%s:%s#127.0.0.1:8332"%(rpcuser, rpcpassword))
Related
I am using OpenGL to render a scene in python. My code works perfectly fine on windows but, for some reason, I'm having issues when importing opengl.gl on MacOS.
The issue arises when calling from OpenGL.GL import ... in both python scripts and the python console.
More specifically here is the exact call in my script:
from OpenGL.GL import glGenBuffers, glBindBuffer, glBufferData, \
glGenVertexArrays, glBindVertexArray, glEnableVertexAttribArray, glVertexAttribPointer, \
glDrawArrays, glUseProgram, glEnable, glDisable, \
GL_ARRAY_BUFFER, GL_STATIC_DRAW, GL_DEPTH_TEST, \
GL_FLOAT, GL_FALSE, \
GL_TRIANGLES, GL_LINES, GL_LINE_STRIP
This results in the following error:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/OpenGL/platform/darwin.py", line 35, in GL
return ctypesloader.loadLibrary(
File "/usr/local/lib/python3.8/site-packages/OpenGL/platform/ctypesloader.py", line 36, in loadLibrary
return _loadLibraryWindows(dllType, name, mode)
File "/usr/local/lib/python3.8/site-packages/OpenGL/platform/ctypesloader.py", line 89, in _loadLibraryWindows
return dllType( name, mode )
File "/usr/local/Cellar/python#3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ctypes/__init__.py", line 373, in __init__
self._handle = _dlopen(self._name, mode)
OSError: ('dlopen(OpenGL, 10): image not found', 'OpenGL', None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/iyadboustany/Desktop/lensmaster/Lensmaster.py", line 18, in <module>
from MainWindow import MainWindow
File "/Users/iyadboustany/Desktop/lensmaster/MainWindow.py", line 14, in <module>
from Robot import Robot
File "/Users/iyadboustany/Desktop/lensmaster/Robot.py", line 8, in <module>
from Graphics.Scene import DHNode
File "/Users/iyadboustany/Desktop/lensmaster/Graphics/Scene.py", line 13, in <module>
from OpenGL.GL import glGenBuffers, glBindBuffer, glBufferData, \
File "/usr/local/lib/python3.8/site-packages/OpenGL/GL/__init__.py", line 3, in <module>
from OpenGL import error as _error
File "/usr/local/lib/python3.8/site-packages/OpenGL/error.py", line 12, in <module>
from OpenGL import platform, _configflags
File "/usr/local/lib/python3.8/site-packages/OpenGL/platform/__init__.py", line 36, in <module>
_load()
File "/usr/local/lib/python3.8/site-packages/OpenGL/platform/__init__.py", line 33, in _load
plugin.install(globals())
File "/usr/local/lib/python3.8/site-packages/OpenGL/platform/baseplatform.py", line 97, in install
namespace[ name ] = getattr(self,name,None)
File "/usr/local/lib/python3.8/site-packages/OpenGL/platform/baseplatform.py", line 15, in __get__
value = self.fget( obj )
File "/usr/local/lib/python3.8/site-packages/OpenGL/platform/darwin.py", line 62, in GetCurrentContext
return self.CGL.CGLGetCurrentContext
File "/usr/local/lib/python3.8/site-packages/OpenGL/platform/baseplatform.py", line 15, in __get__
value = self.fget( obj )
File "/usr/local/lib/python3.8/site-packages/OpenGL/platform/darwin.py", line 45, in CGL
def CGL(self): return self.GL
File "/usr/local/lib/python3.8/site-packages/OpenGL/platform/baseplatform.py", line 15, in __get__
value = self.fget( obj )
File "/usr/local/lib/python3.8/site-packages/OpenGL/platform/darwin.py", line 41, in GL
raise ImportError("Unable to load OpenGL library", *err.args)
ImportError: ('Unable to load OpenGL library', 'dlopen(OpenGL, 10): image not found', 'OpenGL', None)
Notes:
Running glxgears works just fine.
I'm running macOS Big Sur beta (20A5343i)
I'm using python 3.8.5
I installed opengl using pip: pip3 install PyOpenGL PyOpenGL_accelerate
This error is because Big Sur no longer has the OpenGL library nor other system libraries in standard locations in the file system and instead uses a cache. PyOpenGL uses ctypes to try to locate the OpenGL library and it fails to find it. Fixing ctypes in Python so that it will find the library is the subject of this pull request
https://github.com/python/cpython/pull/21241
So a future version of Python should resolve the problem.
To fix it now you can edit PyOpenGL file OpenGL/platform/ctypesloader.py changing line
fullName = util.find_library( name )
to
fullName = '/System/Library/Frameworks/OpenGL.framework/OpenGL'
Since I hate the idea of patching a Python package (plus it is really hard to manage that with use of Conda to install said package), I offer this kludge as a workaround for until Python gets its Big Sur (aka Big Nuisance) update:
try:
import OpenGL as ogl
try:
import OpenGL.GL # this fails in <=2020 versions of Python on OS X 11.x
except ImportError:
print('Drat, patching for Big Sur')
from ctypes import util
orig_util_find_library = util.find_library
def new_util_find_library( name ):
res = orig_util_find_library( name )
if res: return res
return '/System/Library/Frameworks/'+name+'.framework/'+name
util.find_library = new_util_find_library
except ImportError:
pass
It's better to change this to
fullName = "/System/Library/Frameworks/{}.framework/{}".format(name,name)
otherwise GLUT won't work. At least, this let me run the Cozmo SDK's 3d stuff again.
FYI, in my case it was:
fullName = '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/OpenGL'
None of these are really very suitable answers - there were several issues with both MacOS and pyOpenGL.
Fortunately, however - everything seems to be working at last if we upgrade to Python3.10 (or above)
When I execute the following statement in my code on my Mac OS X
import json, nltk, requests, time, smtplib, uuid
I have the followiong error:
18/01/22 22:03:15 INFO TaskSetManager: Lost task 235.0 in stage 4.0 (TID 16) on executor localhost: org.apache.spark.api.python.PythonException (Traceback (most recent call last):
File "/usr/local/spark/python/lib/pyspark.zip/pyspark/worker.py", line 98, in main
command = pickleSer._read_with_length(infile)
File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 164, in _read_with_length
return self.loads(obj)
File "/usr/local/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 422, in loads
return pickle.loads(obj)
File "utils.py", line 6, in <module>
import json, nltk, requests, time, smtplib, uuid
File "/Library/Python/2.7/site-packages/nltk/__init__.py", line 114, in <module>
from nltk.collocations import *
File "/Library/Python/2.7/site-packages/nltk/collocations.py", line 39, in <module>
from nltk.metrics import ContingencyMeasures, BigramAssocMeasures, TrigramAssocMeasures
File "/Library/Python/2.7/site-packages/nltk/metrics/__init__.py", line 16, in <module>
from nltk.metrics.scores import (accuracy, precision, recall, f_measure,
File "/Library/Python/2.7/site-packages/nltk/metrics/scores.py", line 16, in <module>
from scipy.stats.stats import betai
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy/stats/__init__.py", line 324, in <module>
from .stats import *
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy/stats/stats.py", line 242, in <module>
import scipy.special as special
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy/special/__init__.py", line 531, in <module>
from ._ufuncs import *
File "numpy.pxd", line 155, in init scipy.special._ufuncs (scipy/special/_ufuncs.c:19983)
ValueError: numpy.dtype has the wrong size, try recompiling
As you can see from log, I'm using python 2,7 and pyspark (spark 1.6).
Maybe the problem is related to the fact that the software tries to use OSX system Python that use a specific version of numpy and I'm not able to understand how can avoid this.
Anyone can help me?
At this link: ValueError: numpy.dtype has the wrong size, try recompiling
the problem is related to the binary distribution of packages that are compiled against a recent version of numpy.
In my case it seems that spark refer the OSX system python ("/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy/stats/stats.py") instead of the "/Library/Python/2.7" i'm using in my virtual env.
The release notes for libarchive state that because of an older version of libarchive being included within MacOS they recommend changing LD_LIBRARY_PATH to point towards the location of the recent copy of libarchive.
I've used this code to try and achieve that but I get an error message when I run the script.
import os
print os.environ.get('LD_LIBRARY_PATH') #Check what the current path is
os.environ['LD_LIBRARY_PATH'] = '/Library/Python/2.7/site-packages/'
print os.environ.get('LD_LIBRARY_PATH') #Check the variable has been set
import libarchive.public
Error:
None
/Library/Python/2.7/site-packages/
Traceback (most recent call last):
File "scratch.py", line 8, in <module>
import libarchive.public
File "/Library/Python/2.7/site-packages/libarchive/public.py", line 1, in <module>
from libarchive.adapters.archive_read import \
File "/Library/Python/2.7/site-packages/libarchive/adapters/archive_read.py", line 7, in <module>
import libarchive.calls.archive_read
File "/Library/Python/2.7/site-packages/libarchive/calls/archive_read.py", line 17, in <module>
c_archive_read_support_filter_all = libarchive.archive_read_support_filter_all
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 378, in __getattr__
func = self.__getitem__(name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 383, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(0x7fb08b741000, archive_read_support_filter_all): symbol not found
I cant find a great answer to this anywhere out there.
It is not clear from the tool documentation, but based on a thread: https://github.com/dsoprea/PyEasyArchive/issues/16 I set another environment variable to the place where the underlying c library could be found. In my case, it was put there by homebrew on my mac.
os.environ['LA_LIBRARY_FILEPATH']='/usr/local/opt/libarchive/lib/libarchive.dylib'
import libarchive.public
worked for me.
I have a small python (2.7) script that works with several threads. One of the threads will read a global list and post an https post request for each one of the entries of this list.
For doing that I saw that the best way is to use python requests module. I have installed it with pip (no problem with that, it is placed in ...Python/2.7/site-packages/requests/...), but, when I import this module in my script, I get an error.
I have created another script with just one line (import requests) to reproduce the error, and I get this:
Traceback (most recent call last):
File "req.py", line 1, in <module>
import requests
File "/Library/Python/2.7/site-packages/requests/__init__.py", line 43, in <module>
import urllib3
File "/Library/Python/2.7/site-packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/Library/Python/2.7/site-packages/urllib3/connectionpool.py", line 11, in <module>
from .exceptions import (
File "/Library/Python/2.7/site-packages/urllib3/exceptions.py", line 2, in <module>
from .packages.six.moves.http_client import (
File "/Library/Python/2.7/site-packages/urllib3/packages/six.py", line 203, in load_module
mod = mod._resolve()
File "/Library/Python/2.7/site-packages/urllib3/packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/Library/Python/2.7/site-packages/urllib3/packages/six.py", line 82, in _import_module
__import__(name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 69, in <module>
from array import array
File "/Users/carlestalenssebastia/Documents/mychip/raspberry pi/array.py", line 3, in <module>
IndexError: list index out of range
Python 2.7.10
MacBook Pro with macOS Sierra (v 10.12)
Am I doing something wrong? Didn't I installed the module in the proper way?
it seems that you're having two modules with the same name array.py
rename your local array.py module to something more unique to resolve this.
take a look at this answer for more info on how to handle this issue and here to learn more on how python import system works.
I'm trying to connect to wiimote via Python on mac osx 10.7.2.
For that I'm trying to use lightblue. When running: import lightblue Python gives me this error.
>>> import lightblue
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lightblue/__init__.py", line 160, in <module>
from _lightblue import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lightblue/_lightblue.py", line 27, in <module>
import _IOBluetooth
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lightblue/_IOBluetooth.py", line 47, in <module>
globals=globals())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/_bridgesupport.py", line 142, in initFrameworkWrapper
_parseBridgeSupport(data, globals, frameworkName)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/_bridgesupport.py", line 42, in _parseBridgeSupport
objc.parseBridgeSupport(data, globals, frameworkName, *args, **kwds)
ValueError: cftype for 'IOBluetoothDeviceInquiryRef' must include gettypeid_func, tollfree or both
I found one with a similar problem here: http://python.6.n6.nabble.com/Python-bridgesupport-issue-on-Lion-td2161049.html#a32196961 but the answer doesn't help me much, since it seems to me that it is already using lightblue's files. Any suggestions?
Seems like a bug with Apple's gen_bridge_metadata script. You can make the error go away by editing the generated file by hand.
Open up /System/Library/Frameworks/IOBluetooth.framework/Versions/Current/Resources/BridgeSupport/IOBluetooth.bridgesupport and delete the lines that start with <cftype.