uv icon indicating copy to clipboard operation
uv copied to clipboard

Wrong architecture detected for library install with Nix on M1

Open LazyYuuki opened this issue 1 year ago • 4 comments

I discover a niche problem with uv in my use case with Nix on MacOS M1 machine.

I first install uv using nix command:

nix profile install nixpkgs#uv

The version of uv on nix package is 0.1.8. Then I create a venv using uv:

uv venv --seed

And I activate the venv. I tried to open up a .ipynb in VSCode and install the ipykernel with:

uv pip install ipykernel

And try to run the code inside the Jupyter Notebook, but then I got this error.

The file '.venv/lib/python3.10/site-packages/psutil/_psutil_osx.abi3.so, 0x0002' seems to be overriding built in modules and interfering with the startup of the kernel. Consider renaming the file and starting the kernel again.

I then tried to install:

uv pip install jupyter

I have a problem where the package installed is in x86 format not arm64 so it is not compatible and cannot be run. The same happened with the Gradio package.

I delete the old .venv and created a brand new .venv this time I use pip inside the venv to install all the package, it run fine with the correct package architecture.

I then uninstall uv from my nix environtment, install uv using the method recommended on the page instead, and now everything work as intended.

I think there is something happened when uv is installed onto nix in MacOS M1 that caused it to mistake the arch as x86 meanwhile it is actually arm64. It is quite a niche problem, hope you can get a look into it as other might come pass it in the future.

LazyYuuki avatar Feb 24 '24 17:02 LazyYuuki

Do you see the correct behavior if you install uv outside of nix? (We fixed this bug in https://github.com/astral-sh/uv/pull/1843, but that went out in v0.1.7, so perhaps there's something nix-specific there.)

charliermarsh avatar Feb 24 '24 17:02 charliermarsh

Do you see the correct behavior if you install uv outside of nix? (We fixed this bug in #1843, but that went out in v0.1.7, so perhaps there's something nix-specific there.)

Yes the correct behaviour is observed outside of nix using the method recommended to install for MacOS using the install.sh script. It only happened when I am trying to use uv inside nix or a nix shell.

LazyYuuki avatar Feb 24 '24 17:02 LazyYuuki

Great, thanks! Sounds like it's time for me to install Nix...

charliermarsh avatar Feb 24 '24 22:02 charliermarsh

I actually think this might be fixed. Can you give it a try with the latest release?

charliermarsh avatar Mar 18 '24 20:03 charliermarsh

Hi @charliermarsh, it works!!!

Thanks a lot for the help. I have been recommending everyone that I know of and all the people in my workshop to use uv recently (albeit windows is a real headache with the path resolution for beginner in my workshop), absolutely love what you all are building.

Keep up the good work, I am waiting for the Cargo for Python dream soon!

LazyYuuki avatar Mar 19 '24 02:03 LazyYuuki