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

Can't install spacy package as a module #13599

Open
KennethEnevoldsen opened this issue Aug 15, 2024 · 4 comments
Open

Can't install spacy package as a module #13599

KennethEnevoldsen opened this issue Aug 15, 2024 · 4 comments

Comments

@KennethEnevoldsen
Copy link
Contributor

When installing a spaCy-based model from Huggingface a user of DaCy discovered this error:

$ pip install https://huggingface.co/spacy/en_core_web_sm/resolve/main/en_core_web_sm-any-py3-none-any.whl

ERROR: Invalid requirement: 'en-core-web-sm==any': Expected end or semicolon (after name and no valid version specifier)
    en-core-web-sm==any
                                ^

Related to: centre-for-humanities-computing/DaCy#288

I will probably have the time to look at it sometime during September, but wanted to let you about the issue as well. A temporary solution is to downgrade pip:

pip install "pip<22"
pip install https://huggingface.co/spacy/en_core_web_sm/resolve/main/en_core_web_sm-any-py3-none-any.whl

Your Environment

  • spaCy version: 3.7.5
  • Platform: macOS-14.5-arm64-arm-64bit
  • Python version: 3.10.10
@Nue12
Copy link

Nue12 commented Aug 27, 2024

I also had the same issue

  • spaCy version: 3.7.6
  • Platform: macOS-14.4.1
  • Python version: 3.12.3

@michalkvasnicak
Copy link

michalkvasnicak commented Sep 18, 2024

@Nue12 @KennethEnevoldsen I found that you should prefix the URL with package name:

pip install "xx_sent_ud_sm @ https://huggingface.co/spacy/xx_sent_ud_sm/resolve/main/xx_sent_ud_sm-any-py3-none-any.whl"

See https://pip.pypa.io/en/stable/cli/pip_install/#examples under point 7.

  • Python version: 3.12.6
  • PIP version: 24.2
  • Platform: macOS 14.6.1

@Huertas97
Copy link

Huertas97 commented Sep 21, 2024

@Nue12 @KennethEnevoldsen I found that you should prefix the URL with package name:

pip install "xx_sent_ud_sm @ https://huggingface.co/spacy/xx_sent_ud_sm/resolve/main/xx_sent_ud_sm-any-py3-none-any.whl"

See https://pip.pypa.io/en/stable/cli/pip_install/#examples under point 7.

  • Python version: 3.12.6
  • PIP version: 24.2
  • Platform: macOS 14.6.1

Thank you, I had the same problem and you hit the nail right in the head.

I was curious about what was the error about. I share with you in case it results of your interest:

Firstly, the error is primarily related to how pip interprets package specifications, rather than being an issue specifically with spaCy itself. Google colab updated from Python 3.8.5 to Python 3.10 link so pip was also updated. That's why we could run the command before and now we got that error.

Let's take the Spacy well-known en_core_web model as example:

!pip install https://huggingface.co/spacy/en_core_web_sm/resolve/main/en_core_web_sm-any-py3-none-any.whl
  • pip is expecting a valid package name and version specifier. When you provide just the URL, pip tries to parse it as a package name and version. With the URL provided, it interprets the URL as a package named en-core-web-sm with an invalid version specifier any, which is not a valid format.

Fix

!pip install "en_core_web_sm @ https://huggingface.co/spacy/en_core_web_sm/resolve/main/en_core_web_sm-any-py3-none-any.whl"

This command uses a specific syntax that tells pip to install the package en_core_web_sm from the provided URL. The @ symbol is used to specify that the package should be installed from a particular source (in this case, the URL). This syntax is valid and allows pip to correctly interpret the command, leading to a successful installation.

Huertas97 added a commit to Huertas97/hub-docs that referenced this issue Sep 21, 2024
The update in the way to install spacy models from the hub comes from how pip parse the URL to check pacage name and version. As it detect's "any" as version, it can raise an error. Adding the name of the package alongside the URL solve this. 
More info in this GitHub issue: explosion/spaCy#13599
@julien-c
Copy link
Contributor

thanks for investigating!

osanseviero pushed a commit to huggingface/hub-docs that referenced this issue Oct 8, 2024
The update in the way to install spacy models from the hub comes from how pip parse the URL to check pacage name and version. As it detect's "any" as version, it can raise an error. Adding the name of the package alongside the URL solve this. 
More info in this GitHub issue: explosion/spaCy#13599
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants