How to install git+https:// from setup.py using install_requires
Question:
I have a project in which I have to install from git+https:
I can make it to work in this way:
virtualenv -p python3.5 bla
. bla/bin/activate
pip install numpy # must have numpy before the following pkg...
pip install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
However, I want to use it in a setup.py file in install_requires
:
from setuptools import setup
setup(install_requires='git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI', setup_requires='numpy')
and then, pip install -e .
from the dir containing the setup.py
This doesn’t work due to parse error:
Complete output (1 lines):
error in bla_bla setup command: 'install_requires' must be a string or list of strings containing valid project/version requireme
nt specifiers; Invalid requirement, parse error at "'+https:/'"
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
The error doesn’t occur if I install using pip install -r requires.txt
(assuming I have the same string in that file) and not when using direct pip install git+...
…
How to fix this parsing error?
What I’ve tried so far:
- wrapping the string with ” / “”” / ‘ / ”’
- adding ‘r’ before the string
Answers:
install_requires
must be a string or a list of strings with names and optionally URLs to get the package from:
install_requires=[
'pycocotools @ git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
]
See https://pip.pypa.io/en/stable/reference/requirement-specifiers/ and https://www.python.org/dev/peps/pep-0440/#direct-references
This requires pip install
including pip install .
and doesn’t work with python setup.py install
.
I have a project in which I have to install from git+https:
I can make it to work in this way:
virtualenv -p python3.5 bla
. bla/bin/activate
pip install numpy # must have numpy before the following pkg...
pip install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
However, I want to use it in a setup.py file in install_requires
:
from setuptools import setup
setup(install_requires='git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI', setup_requires='numpy')
and then, pip install -e .
from the dir containing the setup.py
This doesn’t work due to parse error:
Complete output (1 lines):
error in bla_bla setup command: 'install_requires' must be a string or list of strings containing valid project/version requireme
nt specifiers; Invalid requirement, parse error at "'+https:/'"
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
The error doesn’t occur if I install using pip install -r requires.txt
(assuming I have the same string in that file) and not when using direct pip install git+...
…
How to fix this parsing error?
What I’ve tried so far:
- wrapping the string with ” / “”” / ‘ / ”’
- adding ‘r’ before the string
install_requires
must be a string or a list of strings with names and optionally URLs to get the package from:
install_requires=[
'pycocotools @ git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
]
See https://pip.pypa.io/en/stable/reference/requirement-specifiers/ and https://www.python.org/dev/peps/pep-0440/#direct-references
This requires pip install
including pip install .
and doesn’t work with python setup.py install
.