Reputation: 29
I am trying to pip install a dependency named fastrank that is currently installing on 2 different apple intel chip. However, when I try running it on two different mac's with M1 chips, I get the following error below:
***Collecting fastrank
Using cached fastrank-0.7.0.tar.gz (52 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [27 lines of output]
⚠️ Warning: Please use maturin in pyproject.toml with a version constraint, e.g. `requires = ["maturin>=0.12,<0.13"]`. This will become an error.
💥 maturin failed
Caused by: Cargo metadata failed. Does your crate compile with `cargo build`?
Caused by: `cargo metadata` exited with an error: Updating crates.io index
warning: spurious network error (2 tries remaining): http parser error: stream ended at an unexpected time; class=Http (34)
warning: spurious network error (1 tries remaining): http parser error: stream ended at an unexpected time; class=Http (34)
error: failed to get `bzip2` as a dependency of package `fastrank v0.7.0 (/private/var/folders/5l/sppq3g8556nffpc74l_54zv40000gn/T/pip-install-ugbpj9al/fastrank_b60c765ae0df4f76b49d90ab4a21f9f2)`
Caused by:
failed to load source for dependency `bzip2`
Caused by:
Unable to update registry `crates-io`
Caused by:
failed to fetch `https://github.com/rust-lang/crates.io-index`
Caused by:
network failure seems to have happened
if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
Caused by:
http parser error: stream ended at an unexpected time; class=Http (34)
Error running maturin: Command '['maturin', 'pep517', 'write-dist-info', '--metadata-directory', '/private/var/folders/5l/sppq3g8556nffpc74l_54zv40000gn/T/pip-modern-metadata-hdyh51_d', '--interpreter', '/Users/chinwekele/.pyenv/versions/3.7.13/bin/python3']' returned non-zero exit status 1.
Checking for Rust toolchain....
Running `maturin pep517 write-dist-info --metadata-directory /private/var/folders/5l/sppq3g8556nffpc74l_54zv40000gn/T/pip-modern-metadata-hdyh51_d --interpreter /Users/chinwekele/.pyenv/versions/3.7.13/bin/python3`
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
Does anyone have any idea how to solve this error? I have tried using a Rosseta terminal, tried downloading and running various packages thinking they would help, but none has worked. Would appreciate a response.
Upvotes: 0
Views: 4500
Reputation: 516
This is to add further details to @Marcelo Archanjo's reply above. Conda worked for me, and here are the steps :
DISCLAIMER - I am a newbie. If what I did looks odd, you know why :)
If your Mac m1 doesn't have Rosetta2, install and enable it - see source
** I only followed the steps up to "verify that you are using a Rosetta terminal"
Install Miniconda3 x86_64 in the Rosetta2 enabled terminal - source
If the error "zsh: command not found: conda" appears in the last step, in the same terminal, activate Miniconda using
source /Users/[user name here]/opt/miniconda3/bin/activate
conda env list
conda activate /Users/[user name here]/[intel env name here]
What I tried before Conda and did not work:
Installing python with pyenv and using venv
Using VS Code's build-in Create Env toolsource
P.S Ensure absolutely all dependencies you need are installed under this env if you are still seeing errors in your repo
Upvotes: 0
Reputation: 134
For Mac, there is a possible workaround for this problem if you use Conda. The idea is to create an x86 environment on the Mac and do your pip install after that.
conda create -n <name>
conda activate <name>
conda config --env --set subdir osx-64
conda install python=3.8
Here I choose Python 3.8, but you can choose another version.
Upvotes: 2
Reputation: 584
arch -x86_64 brew install [email protected]
/usr/local/Cellar/[email protected]/3.7.13_1/bin/pip3 install fastrank
To make everything easier (so you don't have to provide the full path every time) you can create an alias for intel x86 pip and python like so in .zhsrc:
alias ipython='/usr/local/Cellar/[email protected]/3.7.13_1/bin/python3.7'
alias ipip='/usr/local/Cellar/[email protected]/3.7.13_1/bin/pip3'
and use ipip
and ipython
whenever you want to use the intel x86 versions
Upvotes: 0