Open victoriaagc opened 12 months ago
I have the same error on a M1 Macbook Air.
Hey @kweinmeister , thanks for your suggestions. I used v1.6.42
of libpng
and also needed to make the if (NOT APPLE)
change.
But I couldn't get past the python setup.py build
step. It fails with
make[2]: *** No rule to make target `zlibstatic', needed by `/Users/dev/Documents/pystk/build/lib.macosx-11.1-arm64-cpython-310/pystk.cpython-310-darwin.so'. Stop.
make[1]: *** [CMakeFiles/pystk.dir/all] Error 2
Any idea what might be wrong?
I got it working on my Mac. Here is how I did it. Hopefully it works for others too. Let me know.
First, I followed the work-around above. Before building, in pystk/CMakeLists.txt
, I changed the line
set(ZLIB_LIBRARY zlibstatic) # old line
to
set(ZLIB_LIBRARY "${PROJECT_BINARY_DIR}/lib/zlib/libzlibstatic.a") # new line
Thanks @SPJ0 that did the trick 👍
Also for anyone else reading, if you had previously installed pystk with pip, please pip uninstall it and then build it from source.
I'm leaving this here as the above work arounds did not resolve my issue. For context I was running this project on an M1 Macbook Air.
What ultimately resolved the issue was pip installing Pystk through an emulator. This can be done with a Windows emulator via a VM such as VMware Fusion or Parallels. Even simpler would be to install an IDE that is designated to run on an Intel chip Mac. In my case my preferred IDE is VSCode and I installed the Intel chip VSCode found here:
https://code.visualstudio.com/download
This triggers Rosetta to run the emulated application and I found that I was able to successfully pip install Pystk from a virtual env in the emulated IDE. Building from source was not required. Note Python versions > 3.9.6 have trouble installing Pystk through pip at the time of this post (Spring 2024).
Thank you for sharing this Francis. I was having difficulties installing and successfully importing pystk on an M2 Mac and with some modifications, this approach worked for me.
The general approach is to use a Rosetta based terminal (where the terminal is emulating an Intel architecture) to install an Intel version of Python <= 3.9.6 and then build your virtual environment on top of that Intel version of Python. You then install the necessary packages in that virtual environment from within the Rosetta terminal. The Intel version of VS Code essentially serves as a Rosetta terminal but you can also just open the regular Terminal application in Rosetta mode, as described here: https://www.courier.com/blog/tips-and-tricks-to-setup-your-apple-m1-for-development/.
The key point is that you need an Intel version of Python, as the ARM version of Python seems to result in errors when importing pystk. I installed an Intel Python 3.8.18 using a terminal within the Intel version of VS Code by following the instructions in this guide: https://acrogenesis.com/running-intel-python-on-m1. I then created a venv virtual environment using the built-in command within VS code and installed the packages in requirements.txt into that environment. I think other approaches would also work as long as you're installing both Python and the packages from within a Rosetta terminal but I can confirm the approach I just described worked on an M2 Mac.
This installation was really frustrating and I hope this post makes the installation a little smoother for others.
Describe the bug I am unable to import the
pystk
module after installingPySuperTuxKart
on my MacBook Pro with an Apple M2 chip. The installation ofPySuperTuxKart
reports success, but attempting to importpystk
in Python results in an ImportError related to missing symbols in thelibpng
library.To Reproduce
Expected behavior I expected the
pystk
module to be imported without errors, allowing me to run thecontroller.py
script for my SuperTuxKart game project as part of my coursework.Screenshots
System information:
Additional context
symbol not found in flat namespace '_png_init_filter_functions_neon'
.PySuperTuxKart
using--no-cache-dir
and--force-reinstall
options.PySuperTuxKart
, so it's not a viable workaround.libpng
library on the M2 architecture.PySuperTuxKart
and importpystk
successfully on my system for my coursework.