glumpy
glumpy copied to clipboard
IPython on OSX -- RuntimeError: Freetype library not found
I'm trying to get this code working.
It says it can't find glumpy.
sudo pip install glumpy
Now it says it can't find OpenGL.
sudo pip install pyopengl
Now it's says it can't find freetype. But pip fails to locate that lib. Luckily anaconda works:
conda install freetype
But even though the installation completed successfully, my IPython notebook cell keeps spitting out "RuntimeError: Freetype library not found"
I'm not sure what to do next.
Notebook is here
https://github.com/glumpy/glumpy/blob/master/glumpy/ext/freetype/init.py#L32 digging ^ this is where it's failing. So anaconda must have installed freetype somewhere weird.
You also need the freetype library but on OSX it should be installed. Do you use homebrew ? If yes, then you can brew install freetype
I solved this by finding out where Anaconda had put it and doing:
sudo cp anaconda/lib/libfree* /usr/local/lib
This probably means my iPython notebook is using system Python rather than Anaconda Python, but at least it works.
PS Wow I just noticed you specialise in computational neuroscience. I'm currently trying to use your lib to visualise a neuron's weight Matrix for a backpropagating neural network.
PPS Now I've got that one figured out I'm hitting http://pipad.org/tmp/backend_fail.html -- is there something obvious I'm missing?
You cannot use glumpy from within the Jupyter notebook, you'll have to use regular python shell.
How large is your matrix ?
I was thinking of visualizing the entire network in real time: e.g. a 16x16 grid of input neurons, 50 hidden-layer neurons (each with a 16x16 weight-matrix), 10 classifiers (each with 100 inputs).
Do you know how to organize your display (how many images to be show , size and where) ?
I don't really need visualisation for my current task. But I think it is worth investigating real-time visualisation from IPython Notebooks with an eye to future tasks... It could be very useful in debugging NNs that fail to converge for example. I'm familiar with coding GL ES2 (vertex and fragment shaders).
Ok. If you look at the gloo-image.py example, this might do what you want.
I tried sudo cp anaconda/lib/libfree* /usr/local/lib
and I tried conda install freetype
then I tried brew install freetype
And I am sure that the FREETYPE is right inside both /usr/local/lib and /usr/local/Cellar/freetype/2.7.1/lib
Yet I still got the error of RuntimeError: Freetype library not found
File "/Users/cycleuser/.pyenv/versions/anaconda3-4.0.0/lib/python3.5/site-packages/glumpy/ext/freetype/__init__.py", line 49, in <module> raise RuntimeError('Freetype library not found') RuntimeError: Freetype library not found
I tried python2.7.12, 3.5.2, 3.5.3, 3.6.0, from system, anaconda or brew. The OS is macOS 10.12 I use 21 hours to install each of them and try and fail on each one.
So is there any way that I can be saved?
Can you try (from a python shell):
>>> import ctypes.util
>>> ctypes.util.find_library("freetype")
>>> import ctypes.util
>>> ctypes.util.find_library("freetype")
Nothing shows up , seem like the brew link freetype failed.
I have already copied these files below to /usr/local/lib/
libfreetype.6.dylib
libfreetype.a
libfreetype.dylib
libfreetype.la
Weird, on OSX (sierra), I got:
'/usr/locaL/lib/libfreetype.dylib'
@rougier
Thanks a lot!
Maybe it's caused by the bashrc?
Could you please send me a copy of your bashrc ?
I got the same files in the same locations, and the /usr/local/lib is also added to the PATH , that is really strange~
@rougier Thanks a lot!
I uninstall the Brew and delete all the files generated by Brew. Then I install a brand new brew and everything is ok .
import ctypes.util
ctypes.util.find_library("freetype")
shows:
'libfreetype.dylib'
in iPython with Python 3.5.2.
Cool! Are glumpy examples running ok now ?
Gonna test it again.
Seem like the lib location is wrong some how:
export DYLD_FALLBACK_LIBRARY_PATH="/usr/lib"
export DYLD_FALLBACK_LIBRARY_PATH="/usr/local/lib:DYLD_FALLBACK_LIBRARY_PATH"
export PATH="/usr/local/lib:$PATH"
then it also works
Gonna test it later
while I am using:
python earth.py
it gives me this:
File "earth.py", line 9, in <module>
from glumpy.transforms import Arcball, Viewport, Position
ImportError: cannot import name 'Arcball'
There may be some other problems and I will explore later~
@rougier
Same problem as last year. I just change Arcball to Trackball and it works.
I met the same problem after I updated the Mac OS X, so this problem arises depending on the version of the OS X, and I managed to find a solution, just changing line 40 in https://github.com/glumpy/glumpy/blob/master/glumpy/ext/freetype/init.py to:
__dll__ = ctypes.CDLL('/opt/X11/lib/libfreetype.6.dylib')
, or any path of libfreetype.6.dylib.
I'm not sure if I should open a new issue for this, but ctypes.util.find_library
does not properly locate Homebrew-installed "freetype" in my M1 Mac.
It is probably due to the fact that Homebrew does not write to /usr/local/lib
anymore on M1 macs; the path to libfreetype.dylib
on my Mac is /opt/homebrew/lib/libfreetype.dylib
.
Is there a better way than to manually changing the line
FT_Library_filename = ctypes.util.find_library('freetype')
to
FT_Library_filename = "/opt/homebrew/lib/libfreetype.dylib"
in ext/freetype/__init__.py
?
Thanks for the report. This should be reproted to ctypes I think. There is not much I can do.