Installing a pip package from a local SVN checkout - python

I have a clone of another python project (that has a setup.py etc.) in my svn repository. I want to install tell pip to install from this directory. However it's an internal svn repo and is accessible via the svn:// scheme, not http://.
I can checkout the directory fine like so svn co svn://172.31.1.3/Development/Common/ThirdParty/Python/package/our-version ./foobar, then install it with pip: pip install foobar/, however I can't make it do it all in one go.
Here is what I've tried and the output:
pip install svn://172.31.1.3/Development/Common/ThirdParty/Python/package/our-version
...
File ".../virtualenv/lib/python2.5/site-packages/pip-0.7.2-py2.5.egg/pip/vcs/__init__.py", line 110, in get_url_rev
url = self.url.split('+', 1)[1]
IndexError: list index out of range
and
pip install svn+svn://172.31.1.3/Development/Common/ThirdParty/Python/package/our-version
...
File "...virtualenv/lib/python2.5/site-packages/distribute-0.6.10-py2.5.egg/pkg_resources.py", line 2424, in scan_list
raise ValueError("Expected "+item_name+" in",line,"at",line[p:])
ValueError: ('Expected version spec in', 'svn+svn://172.31.1.3/Development/Common/ThirdParty/Python/package/our-version', 'at', '+svn://172.31.1.3/Development/Common/ThirdParty/Python/package/our-version')
Both of these problems happen with or without #egg=packagename at the end of the URL (with the same error message).
and as an editable URL:
pip install -e svn://172.31.1.3/Development/Common/ThirdParty/Python/package/our-version#egg=package
Obtaining package from svn+svn://172.31.1.3/Development/Common/ThirdParty/Python/package/our-version#egg=package
Checking out svn://172.31.1.3/Development/Common/ThirdParty/Python/package/our-version#egg=package to ../virtualenv/src/package
svn: URL 'svn://172.31.1.3/Development/Common/ThirdParty/Python/package/our-version#egg=package' is not properly URI-encoded
So SVN complains if there's a #egg=package at the end of the url, and if i leave it out, I get this error:
pip install -e svn://172.31.1.3/Development/Common/ThirdParty/Python/package/our-version
--editable=svn://172.31.1.3/Development/Common/ThirdParty/Python/package/our-version is not the right format; it must have #egg=Package
How do I install a package from an SVN link with pip?

It is an open bug right now. Paul Nasrat is taking a look at it and opened and issue.
Follow the https://github.com/pypa/pip/issues/252

Related

Unable to find installation candidates for nvidia-cudnn-cu11 when trying to install kornia

I'm trying to install kornia using poetry.
System details
Python 3.8.5 (I have to use this version)
poetry 1.1.13 (upgrading to v1.2 is not an option)
I've previously installed kornia (poetry add kornia) but for some unknown reason I'm now getting the following traceback:
RuntimeError
Unable to find installation candidates for nvidia-cudnn-cu11
(8.5.0.96)
at ~.poetry\lib\poetry\installation\chooser.py:72 in choose_for
68│
69│ links.append(link)
70│
71│ if not links:
→ 72│ raise RuntimeError(
73│ "Unable to find installation candidates for {}".format(package)
74│ )
Since this wasn't a very helpful traceback I thought I'd try to pip install to see if I could get kornia installed somehow, then repeat the process using poetry.
First I ran poetry run pip install nvidia-pyindex, then poetry run pip install kornia. kornia was installed, giving me confidence that I might be able to do the same using poetry.
So I ran poetry add nvidia-pyindex which installed, but when I ran poetry add kornia I got the same RuntimeError.
I wondered if having poetry add without pip uninstall might have caused issues. So I started from scratch - I ran:
rm -rf ~/.cache/pypoetry/cache/repositories/pypi/
poetry rm {name of venv}
git checkout master pyproject.toml poetry.lock
poetry add nvidia-pyindex
which created the venv (by the same name as previously - not sure if this is an issue in itself, since the name of the venv was first created in PyCharm and I wonder if there are some files lingering in places I don't know that is the root of my problems?), then poetry add kornia but got the same error.
I also tried to clear poetry's cache as suggested here but that didn't help. I didn't find a solution here. I don't believe this applies since poetry was installed properly and is working fine otherwise. I read through this but didn't see any working solution. I tried a fix mentioned here, which was to add
[[tool.poetry.source]]
name = "nvidia"
url = "https://pypi.ngc.nvidia.com"
secondary = true
to pyproject.toml, hoping that it would avoid the error when poetry tries to install nvidia-cudnn-cu11, but it didn't help either.
I tried poetry add nvidia-cudnn-cu11 and poetry add nvidia-cudnn-cu116 hoping that having added the ndvidia repo as a secondary source would get kornia's dependencies installed before trying to install kornia itself.
{I don't know if secondary sources are only used when poetry adding a package (i.e. kornia) and "ignored" for installation of dependencies (nvidia-cudnn-cu11) of the package to be installed (kornia).}
In any case, that didn't work either.
Running poetry source add nvidia https://pypi.ngc.nvidia.com didn't work - presumably because poetry source add was added to poetry v1.2 and was not part of v1.1.13.
I also tried poetry add --source nvidia https://pypi.ngc.nvidia.com but I got
PermissionError
[Errno 13] Permission denied:
'C:\Users\...\AppData\Local\Temp\tmp2t6am7ei'
at ~.poetry\lib\poetry\utils\helpers.py:101 in download_file
97│
98│ with get(url, stream=True) as response:
99│ response.raise_for_status()
100│
→ 101│ with open(dest, "wb") as f:
102│ for chunk in response.iter_content(chunk_size=chunk_size):
103│ if chunk:
104│ f.write(chunk)
I'm out of ideas and hoped someone might help.
could this be related to this problem?
https://github.com/python-poetry/poetry/issues/6939
https://github.com/pytorch/pytorch/issues/88049
I had a similar issue and was able to fix it by making the torch dependency explicit and install torch version < 1.13:
[tool.poetry.dependencies]
...
torch = "~1.12.1"

How to add kaleido package to poetry.lock file?

When attempting to install "kaleido" via Poetry, I receive the following error message:
~ poetry add kaleido
Using version ^0.2.1 for kaleido
Updating dependencies
Resolving dependencies... (3.1s)
Package operations: 1 install, 0 updates, 0 removals
• Installing kaleido (0.2.1.post1): Failed
RuntimeError
Unable to find installation candidates for kaleido (0.2.1.post1)
at ~/.poetry/lib/poetry/installation/chooser.py:72 in choose_for
68│
69│ links.append(link)
70│
71│ if not links:
→ 72│ raise RuntimeError(
73│ "Unable to find installation candidates for {}".format(package)
74│ )
75│
76│ # Get the best link
However, the "kaleido" appears in the poetry.lock file:
[[package]]
name = "kaleido"
version = "0.2.1.post1"
description = "Static image export for web-based visualization libraries with zero dependencies"
category = "main"
optional = false
python-versions = "*"
If I try to export an image, I unsurprisingly receive the following error message:
ValueError:
Image export using the "kaleido" engine requires the kaleido package,
which can be installed using pip:
$ pip install -U kaleido
Does anyone know how to install this package via poetry (or amend the .lock file to do it manually)?
Firstly try to use a master version of poetry as advised in Github issue
or upgrade it to the latest version
pip3 install --upgrade poetry
Then try to install with kaleido with locked version:
poetry add kaleido==0.2.1
That worked in my case.

Trying to install a tool from GitHub, but getting lots of errors

I am trying to install pdfminer from GitHub, and I am encountering some errors.
This threw an error:
pip install git+git://github.com/pdfminer/pdfminer.six
This threw an error:
pip install git+https://github.com/pdfminer/pdfminer.six
This threw an error:
git clone https://github.com/pdfminer/pdfminer.six
I googled for a solution online and found the ideas, listed above, from here:
How to install Python package from GitHub?
Those commands seemed to work for several other people, but these don't work for me. I am trying to run these three commands in the Anaconda Prompt. I am using Python 3.6.
Maybe something is not configured correctly on my side, but I can't imagine what it is. Or, is it something else?
BTW, here are the errors that I get:
(base) C:\Users\Excel>pip install https://github.com/pdfminer/pdfminer.six
Collecting https://github.com/pdfminer/pdfminer.six
Downloading https://github.com/pdfminer/pdfminer.six
\ 102kB 1.3MB/s
Cannot unpack file C:\Users\Excel\AppData\Local\Temp\pip-unpack-6kqx4igo\pdfmi
ner.six (downloaded from C:\Users\Excel\AppData\Local\Temp\pip-req-build-2bpsgsh
0, content-type: text/html; charset=utf-8); cannot detect archive format
Cannot determine archive format of C:\Users\Excel\AppData\Local\Temp\pip-req-bui
ld-2bpsgsh0
(base) C:\Users\Excel>pip install git+https://github.com/pdfminer/pdfminer.six
Collecting git+https://github.com/pdfminer/pdfminer.six
Cloning https://github.com/pdfminer/pdfminer.six to c:\users\excel\appdata\loc
al\temp\pip-req-build-iqvj3zbl
Error [WinError 2] The system cannot find the file specified while executing c
ommand git clone -q https://github.com/pdfminer/pdfminer.six C:\Users\Excel\AppD
ata\Local\Temp\pip-req-build-iqvj3zbl
Cannot find command 'git' - do you have 'git' installed and in your PATH?
(base) C:\Users\Excel>git clone https://github.com/pdfminer/pdfminer.six
'git' is not recognized as an internal or external command,
operable program or batch file.
I don't think you're cloning the correct url. You're getting the same "could not unpack" error as the question you linked, hinting that it might be the exact same problem.
Try:
pip install git+https://github.com/pdfminer/pdfminer.six.git
or
pip install git+git://github.com/pdfminer/pdfminer.six.git
Typically git repos end with .git, and when I added it to my clipboard from github that's the url I got.
You could also try pip install pdfminer.six, which I copied directly from their documentation: https://github.com/pdfminer/pdfminer.six/blob/master/README.md

pip: Missing distribution spec. How to fix this?

I am getting following error while running this command on my virtual machine:
$ sudo pip install -U -v --no-deps -b /tmp/piyush/ /tmp/piyush/common_bundle
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.6-py2.7.egg/pip/_vendor/pkg_resources/__init__.py", line 2807, in parse_requirements
raise ValueError("Missing distribution spec", line)
ValueError: ('Missing distribution spec', '/tmp/piyush/common_bundle')
My input file is an archive.
$ file common_bundle
common_bundle: Zip archive data, at least v2.0 to extract
The version of pip is:
$ pip -V
pip 6.0.6 from /usr/local/lib/python2.7/dist-packages/pip-6.0.6-py2.7.egg (python 2.7)
Here is the pip manifest present in the common_bundle:
# This is a pip bundle file, that contains many source packages
# that can be installed as a group. You can install this like:
# pip this_file.zip
# The rest of the file contains a list of all the packages included:
PyYAML==3.10
boto==2.6.0
msgpack-python==0.2.2
tornado==2.1.1
ujson==1.22
virtualenv==1.8.2
bottle==0.10.7
raven==2.0.3
protobuf==2.4.1
# These packages were installed to satisfy the above requirements:
simplejson==2.4.0
distribute==0.6.32
Does anything look fishy?
Thanks.
When pip installing from an archive, the file must either have the proper extension or you need to explicitly use the file:// protocol. Rename your file to /tmp/piyush/common_bundle.zip or use file:///tmp/piyush/common_bundle.
The error you're seeing has nothing to do with the contents of the archive, pip hasn't even unpacked it yet.
Check to see if there are any spaces in your path. This was my problem. Also try keeping the path to the file as short as possible.

"unrecognized .svn/entries format" using buildout

Since upgrading to subversion 1.7 I get "unrecognized .svn/entries format" when running buildout. I notice there is an unresolved bug reports for both distribute and setuptools for this error and it also seems that you can use setuptools_subversion to resolve the issue.
What I can't find out how to do is install setuptools_subversion so that buildout picks it up. Please can someone help?
I've tried
downloading it and running python setup.py install
adding it to the eggs list of the [buildout] part of my buildout configuration
You need to install it at the python site-packages level; easy_install (used under the hood by buildout) needs it available before it'll install anything else.
That said, the python setup.py install stanza should have installed it just fine; check by running the following test:
$ python -m setuptools_subversion
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/setuptools_subversion.py directory
That should print the installation path of the module, like it did for me in the above example. You could try to use pip or easy_install for automatic download:
$ pip install setuptools_subversion
or
$ easy_install setuptools_subversion
You can do that in a virtualenv if you want to isolate the installation. Because this is basically a dependency for svn 1.7, installing this at the same level as the svn binary (usually system wide) is certainly acceptable and the norm.
Note that the unrecognized .svn/entries format error message will not disappear, but your buildout will otherwise succeed. The message is printed no matter what as easy_install first tries the internal .svn parser before deferring to the external plugin.
If you really, really want to verify if the plugin is installed, run the following python code:
import pkg_resources
for entrypoint in pkg_resources.iter_entry_points('setuptools.file_finders'):
print entrypoint
On my system this prints:
svn = setuptools_subversion:listfiles
svn_cvs = setuptools.command.sdist:_default_revctrl
git = setuptools_git:gitlsfiles
hg = setuptools_hg:hg_file_finder

Categories