Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Illegal instruction when importing polars on mac osx #12454

Closed
2 tasks done
paulf81 opened this issue Nov 14, 2023 · 10 comments
Closed
2 tasks done

Illegal instruction when importing polars on mac osx #12454

paulf81 opened this issue Nov 14, 2023 · 10 comments
Labels
bug Something isn't working python Related to Python Polars reference Reference issue for recurring topics

Comments

@paulf81
Copy link

paulf81 commented Nov 14, 2023

Checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

conda create -n test_env python
conda activate test_env
pip install polars
python

Log output

Python 3.12.0 | packaged by Anaconda, Inc. | (main, Oct  2 2023, 12:29:27) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import polars
Illegal instruction: 4

Issue description

Lately when installing polars into a clean conda environment I get an error "Illegal instruction: 4" as an output.

Expected behavior

I am currently not able to import polars into a conda environment in which both python and polars versions are not specifically mentioned on mac os.

Installed versions

Using cached polars-0.19.13-cp38-abi3-macosx_10_12_x86_64.whl.metadata (14 kB)

@paulf81 paulf81 added bug Something isn't working python Related to Python Polars labels Nov 14, 2023
@paulf81
Copy link
Author

paulf81 commented Nov 14, 2023

I installed polars-lts-cpu based on this section:
https://github.com/pola-rs/polars#legacy

And now imports successfully, so maybe same issue as others

@paulf81
Copy link
Author

paulf81 commented Nov 14, 2023

I guess my question is, I can make it work on my machine, but if polars is a requirement of a repository and so I can't be sure where it will be installed, is the safer option to require < python 3.12 to avoid this issue?

@paulf81
Copy link
Author

paulf81 commented Nov 14, 2023

For what it's worth, I've found I can successfully import up to 0.19.5 but any version after that has this issue

@alexander-beedie
Copy link
Collaborator

alexander-beedie commented Nov 14, 2023

I can see that your wheel references x86_64; assuming your machine is running an M1/M2/M3 chip, is your conda version native for Apple Silicon? If it is not then you must run the polars-lts-cpu build as Rosetta translation (which allows x86_64 code to run on these chips) cannot handle AVX instructions. However, if you have the native version of conda then you should have no trouble here...

@paulf81
Copy link
Author

paulf81 commented Nov 15, 2023

Thank you for this response! I've found that polars-lts-cpu does work on my machine. So that does resolve the issue on my machine. But I think from the perspective of having a dependency to polars, pinning to 0.19.5 is the more general solution because up to this version we don't need to specify a special build.

@ritchie46
Copy link
Member

pinning to 0.19.5 is the more general solution because up to this version we don't need to specify a special build.

No it is not? If you want to run under rosetta, you need to use polars-lts-cpu. That's intended.

@paulf81
Copy link
Author

paulf81 commented Nov 16, 2023

Thank you very much for your reply! But, how should I package my project that relies on polars for cross-platform support? Should I specify the LTS version for everyone as the common denominator?

@paulf81
Copy link
Author

paulf81 commented Nov 30, 2023

Could I request an opinion on this solution? In our repo, polars is a requirement, I was thinking a more correct approach than specifying the LTS version as a common denominator, would be to add a "mac" option to the pip install such that if selected the LTS version is installed in place of the normal distribution. Thanks very much for any suggestions!!!

@orlp
Copy link
Collaborator

orlp commented Dec 1, 2023

@paulf81 The real answer is to install the correct version of Python on the M* Mac machines, instead of the emulated Rosetta version.

We already have an issue open for doing better detection of the CPU capabilities and giving a proper error message instead of just an illegal instruction error: #11658.

@orlp orlp closed this as not planned Won't fix, can't repro, duplicate, stale Dec 1, 2023
@paulf81
Copy link
Author

paulf81 commented Dec 1, 2023

@paulf81 The real answer is to install the correct version of Python on the M* Mac machines, instead of the emulated Rosetta version.

We already have an issue open for doing better detection of the CPU capabilities and giving a proper error message instead of just an illegal instruction error: #11658.

This is very helpful @orlp , thank you very much for your time in responding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python Related to Python Polars reference Reference issue for recurring topics
Projects
None yet
Development

No branches or pull requests

4 participants