I am trying to include the ray into my own package. However, there are some dependencies needed for using ray that should be installed via pip install ray[all].
If I just add ray[all] into the install_requires of setup.py, like:
setup(
...
install_requires=[
...
"ray==1.0.0",
"ray[all]==1.0.0",
]
)
Then running pip install -e . can not install the dependencies specified in ray[all]. However, I wish my user can install everything simply via running pip install -e ..
Can anyone provide a solution for this issue? Thanks!
Try pip install -e .[all].
In general pip install -e .[extras] should work for all python packages that are packaged with setuptools.
Related
pip supports installing extra components while installing a Python package from internet, e.g.,
pip install dask[all]
pip install "dask[all] # git+https://github.com/dask/dask"
However, does it support installing extra components when installing from a local Python package? For example, if I have the dask Python package downloaded to local, how can I install it with specific extra components?
I've just figured it out.
pip3 install "dsutil[cv] # file:///home/dclong/dsutil-0.54.1-py3-none-any.whl"
Yes, you can install extras from a local package. If they're defined in the package's setup.py file in the extras_require dictionary, then you can install them with pip install ."[extra1, extra2]". For example, if you have the following in your setup.py:
extras_require={
'docs': ["sphinx>=1.6", "sphinx_rtd_theme>=0.2.4", "sphinx-click"],
'dev': ["pre-commit>=2.10.0"]
},
you can install the docs and dev extras with pip install ".[docs, dev]" when you're in the directory containing setup.py (you'd use the path to the directory containing setup.py in the place of . otherwise).
I bundle my package as a sdist zip file , after that i can import my package anywhere using pip install , but i want to run some post install commands automatically after calling pip install.
I cannot use python setup.py install because it is a sdist and i am using pip to install it . I do have a PostInstall class but nothing runs after pip install package. Is there a way to automatically run a script after pip install package.
I have tried using postinstall but it doesnt work and also i am not sure how to use the scripts atrib in the setup method.
This is my setup.py file :
Setup.py
I cannot use python setup.py install because it is a sdist and i am using pip to install it . I do have a MyInstall class but nothing run after pip install package.
I am not interested in installing my package itself but I am interested installing all the dependencies used by my package. Is there a way to do this using setup.py? It seems setup.py installs my package and all dependencies.
Use the -e flag on pip install
pip install -e .
The only way I've found to reliably do this in a straightforward manner is this:
pip install . && pip uninstall `python setup.py --name`
if you wan to do it from setup.py do:
python setup.py egg_info
pip install -r *.egg-info/requires.txt
rm -rf *.egg-info/
all of this ran from the project folder usually for me it's the root of my github where setup.py is.
credits: https://stackoverflow.com/a/53251585/1601580
We are using pip -e . to install our package in editable/development mode, instead of using python setup.py develop. (We have to do so, because we pull packages from the public PyPi server and a private one. This did not worked for us using python setup.py develop.)
But pip -e . does not install test dependencies and I could not find some flag to force it to do so. How do I install test dependencies using pip?
I use extra_require in the setup.py as specified here. For example:
setup(
name="Project-A",
...
extras_require={
'develop': ["mock==2.0.0"],
}
)
And to execute it using pip install:
pip install -e .[develop]
I am trying to install a python software using the requirements file.
>> cat requirements.txt
Cython==0.15.1
numpy==1.6.1
distribute==0.6.24
logilab-astng==0.23.1logilab-common==0.57.1
netaddr==0.7.6
numexpr==2.0.1
ply==2.5
pycallgraph==0.5.1
pyflowtools==0.3.4.1
pylint==0.25.1
tables==2.3.1
wsgiref==0.1.2
So I create a virtual environment
>> mkvirtualenv parser
(parser)
>> pip freeze
distribute==0.6.24
wsgiref==0.1.2
(parser)
>> pip install -r requirements.txt
... and then I packages downloaded but not installed with errors: http://pastie.org/4079800
(parser)
>> pip freeze
distribute==0.6.24
wsgiref==0.1.2
Surprisingly, if I try to manually install each package, they install just fine.
For instance:
>> pip install numpy==1.6.1
(parser)
>> pip freeze
distribute==0.6.24
wsgiref==0.1.2
numpy==1.6.1
I am lost. What is going on?
PS: I am using pip v1.1 and python v2.7.2 with virtualenv and virtualenvwrapper
It looks like the numexpr package has an install-time dependency on numpy. Pip makes two passes through your requirements: first it downloads all packages and runs each one's setup.py to get its metadata, and then it installs them all in a second pass.
So, numexpr is trying to import from numpy in its setup.py, but when pip first runs numexpr's setup.py, it has not yet installed numpy.
This is also why you don't see this error when you install the packages one by one: if you install them one at a time, numpy will be fully installed in your environment before you pip install numexpr.
The only solution is to install pip install numpy before you ever run pip install -r requirements.txt -- you won't be able to do this in a single command with a single requirements.txt file.
More info here: https://github.com/pypa/pip/issues/25
I come across with a similar issue and I ended up with the below:
cat requirements.txt | sed -e '/^\s*#.*$/d' -e '/^\s*$/d' | xargs -n 1 python -m pip install
That will read line by line the requirements.txt and execute pip. I cannot find from where I got the answer properly, so apologies for that, but I found some justification below:
How sed works: https://howto.lintel.in/truncate-empty-lines-using-sed/
Another similar answer but with git: https://stackoverflow.com/a/46494462/7127519
Hope this help with alternatives.
This is quite annoying sometimes, a bug of pip.
When you run pip install package_name the pip will first run pip check to the target package, and install all the required package for the dependency(target package).
But when you run pip install -r requirements.txt pip will try to directly install all the required packages listed one by one from top to bottom. Sometimes the dependency is listed above the package it depend upon.
The solution is simple:
1.pip install package_name
2.simply put the error package to the bottom of the requirements.txt
3.sometimes a particular version of the package is not be able to be installed,just install the newest version of it and update the data in requirements.txt