spaCy and spaCy models in setup.py
up vote
4
down vote
favorite
In my project I have spaCy as a dependency in my setup.py
, but I want to add also a default model.
My attempt so far has been:
install_requires=['spacy', 'en_core_web_sm'],
dependency_links=['https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz#egg=en_core_web_sm'],
inside my setup.py
, but both a regular pip install
of my package and a pip install --process-dependency-links
return:
pip._internal.exceptions.DistributionNotFound: No matching distribution found for en_core_web_sm (from mypackage==0.1)
I found this github issue from AllenAI with the same problem and no solution.
Note that if I pip install
the url of the model directly, it works fine, but I want to install it as a dependency when my package is install with pip install
.
python setup.py spacy
add a comment |
up vote
4
down vote
favorite
In my project I have spaCy as a dependency in my setup.py
, but I want to add also a default model.
My attempt so far has been:
install_requires=['spacy', 'en_core_web_sm'],
dependency_links=['https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz#egg=en_core_web_sm'],
inside my setup.py
, but both a regular pip install
of my package and a pip install --process-dependency-links
return:
pip._internal.exceptions.DistributionNotFound: No matching distribution found for en_core_web_sm (from mypackage==0.1)
I found this github issue from AllenAI with the same problem and no solution.
Note that if I pip install
the url of the model directly, it works fine, but I want to install it as a dependency when my package is install with pip install
.
python setup.py spacy
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
In my project I have spaCy as a dependency in my setup.py
, but I want to add also a default model.
My attempt so far has been:
install_requires=['spacy', 'en_core_web_sm'],
dependency_links=['https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz#egg=en_core_web_sm'],
inside my setup.py
, but both a regular pip install
of my package and a pip install --process-dependency-links
return:
pip._internal.exceptions.DistributionNotFound: No matching distribution found for en_core_web_sm (from mypackage==0.1)
I found this github issue from AllenAI with the same problem and no solution.
Note that if I pip install
the url of the model directly, it works fine, but I want to install it as a dependency when my package is install with pip install
.
python setup.py spacy
In my project I have spaCy as a dependency in my setup.py
, but I want to add also a default model.
My attempt so far has been:
install_requires=['spacy', 'en_core_web_sm'],
dependency_links=['https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz#egg=en_core_web_sm'],
inside my setup.py
, but both a regular pip install
of my package and a pip install --process-dependency-links
return:
pip._internal.exceptions.DistributionNotFound: No matching distribution found for en_core_web_sm (from mypackage==0.1)
I found this github issue from AllenAI with the same problem and no solution.
Note that if I pip install
the url of the model directly, it works fine, but I want to install it as a dependency when my package is install with pip install
.
python setup.py spacy
python setup.py spacy
edited Nov 23 at 21:12
asked Nov 19 at 22:09
w4nderlust
6421920
6421920
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
You can use pip's recent support for PEP 508 URL requirements:
install_requires=[
'spacy',
'en_core_web_sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz',
],
Note that this requires you to build your project with up-to-date versions of setuptools and wheel (at least v0.32.0 for wheel; not sure about setuptools), and your users will only be able to install your project if they're using at least version 18.1 of pip.
More importantly, though, this is not a viable solution if you intend to distribute your package on PyPI; quoting pip's release notes:
As a security measure, pip will raise an exception when installing packages from PyPI if those packages depend on packages not also hosted on PyPI. In the future, PyPI will block uploading packages with such external URL dependencies directly.
Thank you for your answer. I tested it and it actually works fine. I will not adopt it anyway, because I plan to to release the package on PyPI, but will mark as correct anyway. What do you suggest to do for a PyPI package? I was thinking about catching spaCy'sFileNotFoundError
and printing an error messages that suggests to runpython -m spacy download en
, would that be a good compromise?
– w4nderlust
Nov 21 at 22:08
@w4nderlust: That sounds like a good idea to me.
– jwodder
Nov 21 at 22:10
add a comment |
up vote
0
down vote
Not sure if this works for you, but in setup.py
you might try:
os.system('python -m spacy download en')
after calling setuptools.setup(...)
edit:
According to spaCy docs, it looks like you can now add SpaCy models to your requirements.txt via url as well. You should then be able to import the model as a module where it is required:
import en_core_web_sm
nlp = en_core_web_sm.load()
Ref: https://spacy.io/usage/models
I tried it but it doesn't seem to work. I removed mypackage and spaCy from my local environment with pip uninstall, then installed mypackage again withpip install
, it installed mypackage and spaCy, but then from the python interpreterimport spacy
works fine, whilespacy.load('en')
doesn't:FileNotFoundError: [Errno 2] No such file or directory: '/home/piero/dev/venv3/local/lib/python3.6/site-packages/spacy/data/en/__init__.py'
. so I guess pip didn't run the additional line in thesetup.py
.
– w4nderlust
Nov 21 at 22:02
Not sure if you've seen this discussion, but it may be of some help: github.com/explosion/spaCy/issues/2676
– Wes Doyle
Nov 21 at 22:14
1
Thank you for the additional comment and the edit Wes. I actually already install the model through pip rather than the usualpython -m spacy download en
, but it doesn't work insetup.py
directly, you need to do it in the way @jwodder described that unfortunately doesn't work with PyPI.
– w4nderlust
Nov 23 at 21:16
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You can use pip's recent support for PEP 508 URL requirements:
install_requires=[
'spacy',
'en_core_web_sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz',
],
Note that this requires you to build your project with up-to-date versions of setuptools and wheel (at least v0.32.0 for wheel; not sure about setuptools), and your users will only be able to install your project if they're using at least version 18.1 of pip.
More importantly, though, this is not a viable solution if you intend to distribute your package on PyPI; quoting pip's release notes:
As a security measure, pip will raise an exception when installing packages from PyPI if those packages depend on packages not also hosted on PyPI. In the future, PyPI will block uploading packages with such external URL dependencies directly.
Thank you for your answer. I tested it and it actually works fine. I will not adopt it anyway, because I plan to to release the package on PyPI, but will mark as correct anyway. What do you suggest to do for a PyPI package? I was thinking about catching spaCy'sFileNotFoundError
and printing an error messages that suggests to runpython -m spacy download en
, would that be a good compromise?
– w4nderlust
Nov 21 at 22:08
@w4nderlust: That sounds like a good idea to me.
– jwodder
Nov 21 at 22:10
add a comment |
up vote
2
down vote
accepted
You can use pip's recent support for PEP 508 URL requirements:
install_requires=[
'spacy',
'en_core_web_sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz',
],
Note that this requires you to build your project with up-to-date versions of setuptools and wheel (at least v0.32.0 for wheel; not sure about setuptools), and your users will only be able to install your project if they're using at least version 18.1 of pip.
More importantly, though, this is not a viable solution if you intend to distribute your package on PyPI; quoting pip's release notes:
As a security measure, pip will raise an exception when installing packages from PyPI if those packages depend on packages not also hosted on PyPI. In the future, PyPI will block uploading packages with such external URL dependencies directly.
Thank you for your answer. I tested it and it actually works fine. I will not adopt it anyway, because I plan to to release the package on PyPI, but will mark as correct anyway. What do you suggest to do for a PyPI package? I was thinking about catching spaCy'sFileNotFoundError
and printing an error messages that suggests to runpython -m spacy download en
, would that be a good compromise?
– w4nderlust
Nov 21 at 22:08
@w4nderlust: That sounds like a good idea to me.
– jwodder
Nov 21 at 22:10
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You can use pip's recent support for PEP 508 URL requirements:
install_requires=[
'spacy',
'en_core_web_sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz',
],
Note that this requires you to build your project with up-to-date versions of setuptools and wheel (at least v0.32.0 for wheel; not sure about setuptools), and your users will only be able to install your project if they're using at least version 18.1 of pip.
More importantly, though, this is not a viable solution if you intend to distribute your package on PyPI; quoting pip's release notes:
As a security measure, pip will raise an exception when installing packages from PyPI if those packages depend on packages not also hosted on PyPI. In the future, PyPI will block uploading packages with such external URL dependencies directly.
You can use pip's recent support for PEP 508 URL requirements:
install_requires=[
'spacy',
'en_core_web_sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz',
],
Note that this requires you to build your project with up-to-date versions of setuptools and wheel (at least v0.32.0 for wheel; not sure about setuptools), and your users will only be able to install your project if they're using at least version 18.1 of pip.
More importantly, though, this is not a viable solution if you intend to distribute your package on PyPI; quoting pip's release notes:
As a security measure, pip will raise an exception when installing packages from PyPI if those packages depend on packages not also hosted on PyPI. In the future, PyPI will block uploading packages with such external URL dependencies directly.
answered Nov 19 at 22:42
jwodder
32.4k34879
32.4k34879
Thank you for your answer. I tested it and it actually works fine. I will not adopt it anyway, because I plan to to release the package on PyPI, but will mark as correct anyway. What do you suggest to do for a PyPI package? I was thinking about catching spaCy'sFileNotFoundError
and printing an error messages that suggests to runpython -m spacy download en
, would that be a good compromise?
– w4nderlust
Nov 21 at 22:08
@w4nderlust: That sounds like a good idea to me.
– jwodder
Nov 21 at 22:10
add a comment |
Thank you for your answer. I tested it and it actually works fine. I will not adopt it anyway, because I plan to to release the package on PyPI, but will mark as correct anyway. What do you suggest to do for a PyPI package? I was thinking about catching spaCy'sFileNotFoundError
and printing an error messages that suggests to runpython -m spacy download en
, would that be a good compromise?
– w4nderlust
Nov 21 at 22:08
@w4nderlust: That sounds like a good idea to me.
– jwodder
Nov 21 at 22:10
Thank you for your answer. I tested it and it actually works fine. I will not adopt it anyway, because I plan to to release the package on PyPI, but will mark as correct anyway. What do you suggest to do for a PyPI package? I was thinking about catching spaCy's
FileNotFoundError
and printing an error messages that suggests to run python -m spacy download en
, would that be a good compromise?– w4nderlust
Nov 21 at 22:08
Thank you for your answer. I tested it and it actually works fine. I will not adopt it anyway, because I plan to to release the package on PyPI, but will mark as correct anyway. What do you suggest to do for a PyPI package? I was thinking about catching spaCy's
FileNotFoundError
and printing an error messages that suggests to run python -m spacy download en
, would that be a good compromise?– w4nderlust
Nov 21 at 22:08
@w4nderlust: That sounds like a good idea to me.
– jwodder
Nov 21 at 22:10
@w4nderlust: That sounds like a good idea to me.
– jwodder
Nov 21 at 22:10
add a comment |
up vote
0
down vote
Not sure if this works for you, but in setup.py
you might try:
os.system('python -m spacy download en')
after calling setuptools.setup(...)
edit:
According to spaCy docs, it looks like you can now add SpaCy models to your requirements.txt via url as well. You should then be able to import the model as a module where it is required:
import en_core_web_sm
nlp = en_core_web_sm.load()
Ref: https://spacy.io/usage/models
I tried it but it doesn't seem to work. I removed mypackage and spaCy from my local environment with pip uninstall, then installed mypackage again withpip install
, it installed mypackage and spaCy, but then from the python interpreterimport spacy
works fine, whilespacy.load('en')
doesn't:FileNotFoundError: [Errno 2] No such file or directory: '/home/piero/dev/venv3/local/lib/python3.6/site-packages/spacy/data/en/__init__.py'
. so I guess pip didn't run the additional line in thesetup.py
.
– w4nderlust
Nov 21 at 22:02
Not sure if you've seen this discussion, but it may be of some help: github.com/explosion/spaCy/issues/2676
– Wes Doyle
Nov 21 at 22:14
1
Thank you for the additional comment and the edit Wes. I actually already install the model through pip rather than the usualpython -m spacy download en
, but it doesn't work insetup.py
directly, you need to do it in the way @jwodder described that unfortunately doesn't work with PyPI.
– w4nderlust
Nov 23 at 21:16
add a comment |
up vote
0
down vote
Not sure if this works for you, but in setup.py
you might try:
os.system('python -m spacy download en')
after calling setuptools.setup(...)
edit:
According to spaCy docs, it looks like you can now add SpaCy models to your requirements.txt via url as well. You should then be able to import the model as a module where it is required:
import en_core_web_sm
nlp = en_core_web_sm.load()
Ref: https://spacy.io/usage/models
I tried it but it doesn't seem to work. I removed mypackage and spaCy from my local environment with pip uninstall, then installed mypackage again withpip install
, it installed mypackage and spaCy, but then from the python interpreterimport spacy
works fine, whilespacy.load('en')
doesn't:FileNotFoundError: [Errno 2] No such file or directory: '/home/piero/dev/venv3/local/lib/python3.6/site-packages/spacy/data/en/__init__.py'
. so I guess pip didn't run the additional line in thesetup.py
.
– w4nderlust
Nov 21 at 22:02
Not sure if you've seen this discussion, but it may be of some help: github.com/explosion/spaCy/issues/2676
– Wes Doyle
Nov 21 at 22:14
1
Thank you for the additional comment and the edit Wes. I actually already install the model through pip rather than the usualpython -m spacy download en
, but it doesn't work insetup.py
directly, you need to do it in the way @jwodder described that unfortunately doesn't work with PyPI.
– w4nderlust
Nov 23 at 21:16
add a comment |
up vote
0
down vote
up vote
0
down vote
Not sure if this works for you, but in setup.py
you might try:
os.system('python -m spacy download en')
after calling setuptools.setup(...)
edit:
According to spaCy docs, it looks like you can now add SpaCy models to your requirements.txt via url as well. You should then be able to import the model as a module where it is required:
import en_core_web_sm
nlp = en_core_web_sm.load()
Ref: https://spacy.io/usage/models
Not sure if this works for you, but in setup.py
you might try:
os.system('python -m spacy download en')
after calling setuptools.setup(...)
edit:
According to spaCy docs, it looks like you can now add SpaCy models to your requirements.txt via url as well. You should then be able to import the model as a module where it is required:
import en_core_web_sm
nlp = en_core_web_sm.load()
Ref: https://spacy.io/usage/models
edited Nov 21 at 22:14
answered Nov 19 at 22:22
Wes Doyle
6051619
6051619
I tried it but it doesn't seem to work. I removed mypackage and spaCy from my local environment with pip uninstall, then installed mypackage again withpip install
, it installed mypackage and spaCy, but then from the python interpreterimport spacy
works fine, whilespacy.load('en')
doesn't:FileNotFoundError: [Errno 2] No such file or directory: '/home/piero/dev/venv3/local/lib/python3.6/site-packages/spacy/data/en/__init__.py'
. so I guess pip didn't run the additional line in thesetup.py
.
– w4nderlust
Nov 21 at 22:02
Not sure if you've seen this discussion, but it may be of some help: github.com/explosion/spaCy/issues/2676
– Wes Doyle
Nov 21 at 22:14
1
Thank you for the additional comment and the edit Wes. I actually already install the model through pip rather than the usualpython -m spacy download en
, but it doesn't work insetup.py
directly, you need to do it in the way @jwodder described that unfortunately doesn't work with PyPI.
– w4nderlust
Nov 23 at 21:16
add a comment |
I tried it but it doesn't seem to work. I removed mypackage and spaCy from my local environment with pip uninstall, then installed mypackage again withpip install
, it installed mypackage and spaCy, but then from the python interpreterimport spacy
works fine, whilespacy.load('en')
doesn't:FileNotFoundError: [Errno 2] No such file or directory: '/home/piero/dev/venv3/local/lib/python3.6/site-packages/spacy/data/en/__init__.py'
. so I guess pip didn't run the additional line in thesetup.py
.
– w4nderlust
Nov 21 at 22:02
Not sure if you've seen this discussion, but it may be of some help: github.com/explosion/spaCy/issues/2676
– Wes Doyle
Nov 21 at 22:14
1
Thank you for the additional comment and the edit Wes. I actually already install the model through pip rather than the usualpython -m spacy download en
, but it doesn't work insetup.py
directly, you need to do it in the way @jwodder described that unfortunately doesn't work with PyPI.
– w4nderlust
Nov 23 at 21:16
I tried it but it doesn't seem to work. I removed mypackage and spaCy from my local environment with pip uninstall, then installed mypackage again with
pip install
, it installed mypackage and spaCy, but then from the python interpreter import spacy
works fine, while spacy.load('en')
doesn't: FileNotFoundError: [Errno 2] No such file or directory: '/home/piero/dev/venv3/local/lib/python3.6/site-packages/spacy/data/en/__init__.py'
. so I guess pip didn't run the additional line in the setup.py
.– w4nderlust
Nov 21 at 22:02
I tried it but it doesn't seem to work. I removed mypackage and spaCy from my local environment with pip uninstall, then installed mypackage again with
pip install
, it installed mypackage and spaCy, but then from the python interpreter import spacy
works fine, while spacy.load('en')
doesn't: FileNotFoundError: [Errno 2] No such file or directory: '/home/piero/dev/venv3/local/lib/python3.6/site-packages/spacy/data/en/__init__.py'
. so I guess pip didn't run the additional line in the setup.py
.– w4nderlust
Nov 21 at 22:02
Not sure if you've seen this discussion, but it may be of some help: github.com/explosion/spaCy/issues/2676
– Wes Doyle
Nov 21 at 22:14
Not sure if you've seen this discussion, but it may be of some help: github.com/explosion/spaCy/issues/2676
– Wes Doyle
Nov 21 at 22:14
1
1
Thank you for the additional comment and the edit Wes. I actually already install the model through pip rather than the usual
python -m spacy download en
, but it doesn't work in setup.py
directly, you need to do it in the way @jwodder described that unfortunately doesn't work with PyPI.– w4nderlust
Nov 23 at 21:16
Thank you for the additional comment and the edit Wes. I actually already install the model through pip rather than the usual
python -m spacy download en
, but it doesn't work in setup.py
directly, you need to do it in the way @jwodder described that unfortunately doesn't work with PyPI.– w4nderlust
Nov 23 at 21:16
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53383352%2fspacy-and-spacy-models-in-setup-py%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown