explosion / spaCy

💫 Industrial-strength Natural Language Processing (NLP) in Python
https://spacy.io
MIT License
30.36k stars 4.41k forks source link

Can't install spacy package as a module #13599

Open KennethEnevoldsen opened 3 months ago

KennethEnevoldsen commented 3 months ago

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: https://github.com/centre-for-humanities-computing/DaCy/issues/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

Nue12 commented 3 months ago

I also had the same issue

michalkvasnicak commented 2 months ago

@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.

Huertas97 commented 2 months ago

@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

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.

julien-c commented 2 months ago

thanks for investigating!