Closed ff6347 closed 8 years ago
I don't see why it would not be possible, though I can't help you as I don't own a Mac.
hm. My problem is I can't find anything 'agg' related for Mac. Also nothing about 'potrace development packages'. (I installed potrace via macports)
IIRC headers are not separated from libs on macports, you get both when you install a package. "agg" stands for Antigraingeometry, it seems to be available on macports: https://trac.macports.org/browser/trunk/dports/graphics/antigraingeometry/Portfile
Cool.
sudo port install antigraingeometry
Did it. Thanks. But now I get an error while running your setup.py
potrace/_potrace.c:156:10: fatal error: 'potracelib.h' file not found
#include "potracelib.h"
^
1 error generated.
error: command 'clang' failed with exit status 1
Seems like the potrace is missing.
macports placed the header here
/opt/local/include/potracelib.h
So it is there. How can I tell the setup to look also there? Sorry if these are stupid questions. I'm a python rookie
You can change the include dirs in setup.py with the include_dirs argument of Extension, e.g.:
ext_modules = [
Extension("potrace._potrace", ["potrace/_potrace.pyx"],
libraries=["potrace"], include_dirs=['/opt/local/include']),
Extension("potrace.bezier", ["potrace/bezier.pyx"],
libraries=["agg"], language="c++"),
Extension("potrace.agg.curves", ["potrace/agg/curves.pyx"],
libraries=["agg"], language="c++"),
]
Could you make a pull request if you get this to work ?
Shure I will make a pull request. But now I get an error with numpy. That should be in the Python Core , if I'm not mistaken.
The error:
potrace/_potrace.c:159:10: fatal error: 'numpy/arrayobject.h' file not found
#include "numpy/arrayobject.h"
It is located here:
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include/numpy/arrayobject.h
Tried to add the path to the include dirs but it didnot work
ext_modules = [
Extension("potrace._potrace", ["potrace/_potrace.pyx"],
libraries=["potrace"], include_dirs=['/opt/local/include','/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include/numpy']),
Extension("potrace.bezier", ["potrace/bezier.pyx"],
libraries=["agg"], language="c++"),
Extension("potrace.agg.curves", ["potrace/agg/curves.pyx"],
libraries=["agg"], language="c++"),
]
I found this thread cannot find numpy header files https://bugs.archlinux.org/task/22326
Description: When trying to use cython (within python2) to create a module from a numpy scrip, the compilation fails because python/gcc cannot find the required header files that came with numpy.
This seems to be the fix (if I understand it right), but where could I put it to test that:
export CFLAGS=-I/usr/lib/python2.7/site-packages/numpy/core/include/
hm. I managed to import the numpy headers like discribed in the cannot find numpy header files thread. (I get a lot of warnings about unused stuff from numpy but it works.)
setup.py looks liek this now:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy
ext_modules = [
Extension("potrace._potrace", ["potrace/_potrace.pyx"],
libraries=["potrace"], include_dirs=['/opt/local/include',numpy.get_include()]),
Extension("potrace.bezier", ["potrace/bezier.pyx"],
libraries=["agg"], language="c++"),
Extension("potrace.agg.curves", ["potrace/agg/curves.pyx"],
libraries=["agg"], language="c++"),
]
Now the next error.
10 warnings generated.
clang -bundle -undefined dynamic_lookup -Wl,-F. -arch i386 -arch x86_64 build/temp.macosx-10.8-intel-2.7/potrace/_potrace.o -lpotrace -o build/lib.macosx-10.8-intel-2.7/potrace/_potrace.so
ld: library not found for -lpotrace
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
So what does that mean? -lpotrace ? I found another thread where somebody has a similar problem.
He uses a lib that is called parser but it looks for something called lparer
http://forums.macrumors.com/showthread.php?t=703524
This doesn't look like a symbolic link issue, but rather a prompt formatting issue. Double-check your includes line. Somehow, ld thinks that you're trying to specify a library called lparser rather than parser.
-lpotrace means link with the potrace library (that comes from the libraries=["potrace"] option). You have to find where macports puts this file (it should be named "libpotrace.so"), then specify it with the library_dirs as you did with include_dirs, e.g.:
Extension(..., library_dirs=['/directory/that/contains/potrace'])
hi there - its me again,
macports places the libs under /opt/local/lib so my include is like this:
library_dirs=['/opt/local/lib']
Now he passes the error I had before, but there seems to be something wrong libpotrace.dylib: file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386).
clang -bundle -undefined dynamic_lookup -Wl,-F. -arch i386 -arch x86_64 build/temp.macosx-10.8-intel-2.7/potrace/_potrace.o -L/opt/local/lib -lpotrace -o build/lib.macosx-10.8-intel-2.7/potrace/_potrace.so
ld: warning: ignoring file /opt/local/lib/libpotrace.dylib, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): /opt/local/lib/libpotrace.dylib
And afterwards follows again an error with numpy.
skipping 'potrace/bezier.cpp' Cython extension (up-to-date)
building 'potrace.bezier' extension
clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c potrace/bezier.cpp -o build/temp.macosx-10.8-intel-2.7/potrace/bezier.o
clang: warning: argument unused during compilation: '-mno-fused-madd'
potrace/bezier.cpp:201:10: fatal error: 'numpy/arrayobject.h' file not found
#include "numpy/arrayobject.h"
^
1 error generated.
error: command 'clang' failed with exit status 1
Thanks a lot for your help. I will try to work this out another way. Maybe using bash or an Ubuntu machine.
I'm trying to install pypotrace on MaxOSX 10.8, and running into the exact same series of problems. I got as far as the "'potracelib.h' not found" error before realizing this thread didn't actually lead to a solution.
Has anyone yet succeeded in installing pypotrace on a Mac? If so, any tips would be much appreciated!
Yeah, I have the problem with potracelib.h on OS X as well as on Linux, and any suggestions would be appreciated. BTW, the not-automatically-handled dependency Cython.Distutils is kinda' annoying as well.
I've walked through all the steps of @fabiantheblind's unsuccessful attempt, and it ain't started working yet on OS X.
I managed to install pypotrace on Linux though; maybe it's kinda' off-topic, but I have a problem which may be caused by pypotrace: Archiet/armpen#1 (on Linux)
If someone is interested in installing pypotrace on MacOS, try following the steps below:
install potrace and antigraingeometry (agg) from macports: sudo port install potrace sudo port install antigraingeometry
-> it will install libs on /opt/local/lib and the respective include files on /opt/local/include
Determine the location of the site-packages directory. You can get it with:
export PYTHONSITEPKG=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") echo $PYTHONSITEPKG
If you are working from a virtual env with default configuration it should probably look as: /Users/yourlogin/.virtualenvs/yourvirtenv/lib/python2.7/site-packages
Install pypotrace telling the compiler where to find the include files (-I) and the libraries (-L):
pip install \ --global-option=build_ext \ --global-option="-I/opt/local/include:$PYTHONSITEPKG/numpy/core/include" \ --global-option='-L/opt/local/lib' \ pypotrace
(Worked with: MacOS 10.9.4 and Python 2.7.5)
I now have access to a mac and updated the setup.py. It now relies on pkg-config for libagg and build should be more reliable accross platforms. numpy include directories are also now retrieved with numpy.get_include()
.
The README is updated and building should be more simple now. I tried the instructions on OSX 10.10 and Ubuntu 14.04, but I would appreciate if you could try on your systems.
I also regenerated the cython extensions and fixed a segfault when passing None
to Bitmap
constructor.
No news is good news, I'll close the issue. Don't hesitate to reopen it if you encounter any problem.
Hi there, I am on OS 10.11.2, when i did the last step which is $pip install .
It gives me the output below:
Processing /Users/mwang/Desktop/HappyHackers/re/PyOpenGL_season_02/pypotrace
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/73/661v1s_d41j4bv5twvpsykgw0000gp/T/pip-hmzb96jc-build/
Would anybody be so kind to help me?
BTW, i am using Python 3.5.4 :: Anaconda custom (x86_64)
This is a Python 3 issue. It's fixed on github, but apparently not the version on PyPI. Try:
pip3 install -e git+https://github.com/flupke/pypotrace#egg=pypotrace
UPDATE: This is now fixed on PyPI. pip3 install pypotrace
should work.
pip3 install pypotrace
does not work for me but pip3 install -e git+https://github.com/flupke/pypotrace#egg=pypotrace
does.
It's already mentioned at https://github.com/flupke/pypotrace#osx (link), but don't forget to run:
brew install libagg pkg-config potrace
before pip3 install pypotrace
.
Hi all,
I am on OS X Big Sur 11.1.
I have run brew install libagg pkg-config potrace successfully.
I use a conda environment with Python 3.7.4, Cython==0.29.13 and numpy 1.17.4.
Wheter I do pip3 install pypotrace
or pip3 install -e git+https://github.com/flupke/pypotrace#egg=pypotrace
or git clone... pip install .
, I get this error trace:
Installing collected packages: pypotrace
Running setup.py develop for pypotrace
ERROR: Command errored out with exit status 1:
command: /Users/vwrobel/opt/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/Users/vwrobel/Workshop/src/pypotrace/setup.py'"'"'; __file__='"'"'/Users/vwrobel/Workshop/src/pypotrace/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
cwd: /Users/vwrobel/Workshop/src/pypotrace/
Complete output (18 lines):
running develop
running egg_info
writing pypotrace.egg-info/PKG-INFO
writing dependency_links to pypotrace.egg-info/dependency_links.txt
writing requirements to pypotrace.egg-info/requires.txt
writing top-level names to pypotrace.egg-info/top_level.txt
reading manifest file 'pypotrace.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pypotrace.egg-info/SOURCES.txt'
running build_ext
building 'potrace._potrace' extension
x86_64-apple-darwin13.4.0-clang -fno-strict-aliasing -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O3 -Wall -Wstrict-prototypes -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O3 -pipe -fdebug-prefix-map=${SRC_DIR}=/usr/local/src/conda/${PKG_NAME}-${PKG_VERSION} -fdebug-prefix-map=/Users/vwrobel/opt/anaconda3=/usr/local/src/conda-prefix -flto -Wl,-export_dynamic -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O3 -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -isystem /Users/vwrobel/opt/anaconda3/envs/workshop/include -D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9 -isystem /Users/vwrobel/opt/anaconda3/envs/workshop/include -I/Users/vwrobel/.local/lib/python3.7/site-packages/numpy/core/include -I/Users/vwrobel/opt/anaconda3/include/python3.7m -c potrace/_potrace.c -o build/temp.macosx-10.9-x86_64-3.7/potrace/_potrace.o
clang-10: warning: -Wl,-export_dynamic: 'linker' input unused [-Wunused-command-line-argument]
potrace/_potrace.c:618:10: fatal error: 'potracelib.h' file not found
#include "potracelib.h"
^~~~~~~~~~~~~~
1 error generated.
error: command 'x86_64-apple-darwin13.4.0-clang' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Users/vwrobel/opt/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/Users/vwrobel/Workshop/src/pypotrace/setup.py'"'"'; __file__='"'"'/Users/vwrobel/Workshop/src/pypotrace/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.
potracelib.h is symlinked to /usr/local/include by homebrew.
I would appreciate very much any help!
In case anyone runs into the above problem: I could not install pypotrace in a conda environment but it is ok on a virtualenv (I had to reinstall homebrew though in my particular case).
Hi there, I would love to use your lib on Mac OSX 10.8? Is it possible to do that?