pip: Show version of dependencies required - pip

pip show package_name only shows the package dependencies. It does not show the specific version of dependencies required to install that package. For example, pip show datasets has the following lines in its output:
Name: datasets
Version: 2.7.1
...
Requires: pyarrow, tqdm, huggingface-hub, numpy, fsspec, aiohttp, packaging, responses, requests, xxhash, dill, multiprocess, pyyaml, pandas
...
I want to know the specific version of say huggingface-hub that is required by datasets==2.7.1. How can I find that?
I tried pip show --help but it doesn't seem to have any options for this.

Related

Tensorflow js and MacM1

I have a running installation of tensorflow-macos and the metal plugin for mac os M1.
Now I want to convert my trained model in a tensorflow js one.
However, when I run
pip install tensorflowjs I get an error due to the fact that tensorflow js actually depends on tensorflow not on tensorflow-macos.
ERROR: Cannot install tensorflowjs==0.1.0, tensorflowjs==0.1.1, tensorflowjs==0.1.2, tensorflowjs==0.2.0, tensorflowjs==0.2.1, tensorflowjs==0.3.0, tensorflowjs==0.3.1, tensorflowjs==0.4.0, tensorflowjs==0.4.1, tensorflowjs==0.4.2, tensorflowjs==0.5.0, tensorflowjs==0.5.2, tensorflowjs==0.5.4, tensorflowjs==0.5.6, tensorflowjs==0.5.7, tensorflowjs==0.6.0, tensorflowjs==0.6.1, tensorflowjs==0.6.2, tensorflowjs==0.6.4, tensorflowjs==0.6.5, tensorflowjs==0.6.7, tensorflowjs==0.8.0, tensorflowjs==0.8.5, tensorflowjs==0.8.6, tensorflowjs==1.0.1, tensorflowjs==1.1.2, tensorflowjs==1.2.1, tensorflowjs==1.2.10, tensorflowjs==1.2.10.1, tensorflowjs==1.2.2, tensorflowjs==1.2.2.1, tensorflowjs==1.2.3, tensorflowjs==1.2.6, tensorflowjs==1.2.9, tensorflowjs==1.3.1, tensorflowjs==1.3.1.1, tensorflowjs==1.3.2, tensorflowjs==1.4.0, tensorflowjs==1.5.2, tensorflowjs==1.6.0, tensorflowjs==1.7.2, tensorflowjs==1.7.3, tensorflowjs==1.7.4, tensorflowjs==1.7.4.post1, tensorflowjs==2.0.0, tensorflowjs==2.0.1, tensorflowjs==2.0.1.post1, tensorflowjs==2.1.0, tensorflowjs==2.3.0, tensorflowjs==2.4.0, tensorflowjs==2.5.0, tensorflowjs==2.6.0, tensorflowjs==2.7.0, tensorflowjs==2.8.0, tensorflowjs==2.8.1, tensorflowjs==2.8.2, tensorflowjs==2.8.3, tensorflowjs==2.8.4, tensorflowjs==2.8.5, tensorflowjs==3.0.0, tensorflowjs==3.1.0, tensorflowjs==3.11.0, tensorflowjs==3.12.0, tensorflowjs==3.13.0, tensorflowjs==3.14.0, tensorflowjs==3.15.0, tensorflowjs==3.17.0, tensorflowjs==3.18.0, tensorflowjs==3.19.0, tensorflowjs==3.2.0, tensorflowjs==3.20.0, tensorflowjs==3.3.0, tensorflowjs==3.4.0, tensorflowjs==3.5.0, tensorflowjs==3.6.0, tensorflowjs==3.7.0, tensorflowjs==3.8.0 and tensorflowjs==3.9.0 because these package versions have conflicting dependencies.
The conflict is caused by:
tensorflowjs 3.20.0 depends on tensorflow<3 and >=2.1.0
...
tensorflowjs 0.1.1 depends on tensorflow>=1.6.0
tensorflowjs 0.1.0 depends on tensorflow>=1.6.0
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict
Any idea on how to solve it?
just encountered the same problem.
Here is what worked for me.
Install all dependencies of the tensorflowjs package except tensorflow (since you have tensorflow-macos already installed) and then install tensorflowjs without it dependencies.
Install tensorflowjs dependencies :
pip install tensorflow_hub jax scipy jaxlib etils
Install tensorflowjs without its dependencies :
pip install --no-deps tensorflowjs

Pip install package not from pypi, whose name is the same as one in pypi ( + with dependencies from pypi )

I have a python package, hosted on azure (vsts), not on pypi, whose dependencies are python packages that live in pypi.
My package has the same name as a package that lives on pypi, I discovered.
Is there a way of installing my package with pip, specifying that my package must be searched on vsts before, while the dependencies can be grabbed from pypi?
If I use the --index-url option:
pip install <my-package> --index-url https://<my-package>:<PAT>#<url>/<proj>/_packaging/<my-package>/pypi/simple/
pip is able to locate my package, tries to install it, but it fails to install any dependency (because it searches for all of them in the same url, which is wrong because I am not hosting, say, my own version of numpy or other packages on vsts).
(This is the problem: pip install producing "Could not find a version that satisfies the requirement" )
If instead I use the --extra-index-url option:
pip install <my-package> --extra-index-url https://<my-package>:<PAT>#<url>/<proj>/_packaging/<my-package>/pypi/simple/
all the dependencies are found, but the problem is that this does not install my package, but the package with the same name that lives in pypi!
Even if --extra-index-url is there, it seems that pypi is given priority, and therefore my package that would be found at the url I specified is shadowed and doesn't get correctly found and installed.
Is there a way to, say, tell pip that it should give priority to my --extra-index-url? Or to give pip an --index-url which should only be valid for one package but not for its dependencies?
You need index URL pointing to VSTS and extra URL to PyPI:
pip install --index-url=https://<my-package>:<PAT>#<url>/<proj>/_packaging/<my-package>/pypi/simple/ --extra-index-url=https://pypi.org/simple/ <my-package>

Pip extras dependency substitution

I'm creating a module that has only 1 pypi dependency. This dependency has 2 packages on pypi. One that makes use of a system library and the other packages a binary distribution of that library. They look like:
theirmodule
theirmodule-binary
My module depends on theirmodule but I want users of my module to be able to decide if they want the lib version of the dependency or the binary version. I see in the docs about Extras. I could do:
setup(
name="MyModule",
...
extras_require={
"BIN": ["theirmodule-binary>=1.2"]
}
)
But then if the user does pip install mymodule[BIN] pip will install both theirmodule and theirmodule-binary. That would be a conflict since both have the same underlying import string eg:
import theirmodule
is used for both. How can this be handled without providing 2 separate pypi packages?
Maybe something like the following:
setup.py
import setuptools
setuptools.setup(
name='My-Project',
# ...
extras_require={
'Extra_Dependency_As_Binary': ['Dependency-Project-Binary>=1.2'],
'Extra_Dependency_As_Library': ['Dependency-Project-Library<=3.4'],
},
)
And then instruct the users of My-Project (maybe in the README file) to install by specifying either one of the extra explicitly. For example with pip it could be one or the other of:
path/to/pythonX.Y -m pip install 'My-Project[Extra_Dependency_As_Binary]'
path/to/pythonX.Y -m pip install 'My-Project[Extra_Dependency_As_Library]'

Installing specific versions of pyproj from github

I have been trying to install obspy and have been running into a lot of problems. I want to install obspy which has a dependency on pyproj. But apparently obspy only works with pyproj 1.9.5.1, which I tried installing using pip (pip3 install pyproj==1.9.5.1), but only got the errors like-
_proj.c:7488:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
Digging deeper I found that it might be a Cython problem, and installing pyproj directly from github might help, because it would apparently make Cython recompile all the necessary files. Something along the lines of -
pip3 install git+https://github.com/jswhit/pyproj.git
However this one gives the error -
ERROR: Minimum supported proj version is 6.2.0, installed version is 5.2.0.
I di try installing a higher version of libproj-dev (sudo apt install libproj-dev=6.2.0) however it shows that there is no candidate for 6.2.0. I tried downloading the deb file and installing from that using -
sudo apt-get install ~/Downloads/libproj-dev_6.2.0-1_amd64.deb
which just leads to the error -
The following packages have unmet dependencies:
libproj-dev : Depends: libproj15 (= 6.2.0-1) but it is not installable
E: Unable to correct problems, you have held broken packages.
But I think this is not the right way to install for me anyway, since I need a specific version. Hence I tried installing directly from the tarball of the release -
pip3 install https://github.com/pyproj4/pyproj/archive/v1.9.5.1rel.tar.gz
Which leads to the first error I had, evidently due to Cython.
With errors on everything I tried to do to fix this, I am not sure what even is relevant to my problem now.
Any help is appreciated, and if this site is not the correct place for this question, please help me migrate it to its proper destination.
I am on Ubuntu 18.10.
The problem is, that Cython-generated c-files don't work for Python-3.7 if generated with Cython versions up to 0.27.3 (at least): The setup.py of pyproj (at least in the version 1.9.5.1) doesn't regenerate the_proj.c, which is generated with Cython 0.23.2 and thus the installation cannot succeed.
You have the following options:
stay on Python3.6 where everything works out of the box.
regenerate _proj.c with a current Cython-version.
For the second option:
download and unzip your prefered version from https://github.com/pyproj4/pyproj/releases/tag/v1.9.5.1rel and switch to the created folder pyproj-1.9.5.1rel.
check, that the cython-version is >=0.27.3. via cython --version.
regenerate the _proj.c file via cython -3 _proj.pyx (_proj.pyx looks like Python3-code, but also language_level=2 (i.e. cython -2 _proj.pyx) will probably work.
install running pip install .
pyproj 1.9.5.1 was release at Jan 7, 2016. At that time, the latest version Python was 3.5. In my tests. pyproj 1.9.5.1 failed to be installed on Python 3.7.4, but succeeded on Python 3.5.7.
You need to create a environment with Python 3.5 by pyenv or conda.
References
pyproj 1.9.5.1 release
Python release history

python package can be installed by pip but not conda

I need the sacred package for a new code base I downloaded. It requires sacred.
https://pypi.python.org/pypi/sacred
conda install sacred fails with
PackageNotFoundError: Package missing in current osx-64 channels:
- sacred
The instruction on the package site only explains how to install with pip. What do you do in this case?
That package is not available as a conda package at all. You can search for packages on anaconda.org: https://anaconda.org/search?q=sacred You can see the type of package in the 4th column. Other Python packages may be available as conda packages, for instance, NumPy: https://anaconda.org/search?q=numpy
As you can see, the conda package numpy is available from a number of different channels (the channel is the name before the slash). If you wanted to install a package from a different channel, you can add the option to the install/create command with the -c/--channel option, or you can add the channel to your configuration conda config --add channels channel-name.
If no conda package exists for a Python package, you can either install via pip (if available) or build your own conda package. This isn't usually too difficult to do for pure Python packages, especially if one can use skeleton to build a recipe from a package on PyPI.
It happens some issue to me before. If your system default Python environment is Conda, then you could download those files from https://pypi.python.org/pypi/sacred#downloads
and manually install by
pip install C:/Destop/some-file.whl

Resources