pip cannot find module that is in pypi - python

I have created a python module, i2cdev.
pypi link: https://pypi.python.org/pypi?%3Aaction=pkg_edit&name=i2cdev
git link: https://github.com/cloudformdesign/i2cdev
When I try to install it through pip, I get that it cannot find it:
$ pip3 search "i2cdev" # finds it fine
i2cdev - Simple I2C Library for linux
$ pip3 install i2cdev
Collecting i2cdev
Could not find any downloads that satisfy the requirement i2cdev
No distributions at all found for i2cdev
What is going on?

wow, I'm an idiot. Apparently you have to use setup.py sdist upload to actually upload the code onto python. I thought just registering it was enough.

You have to setup download link for the tarball/zip file which is uploaded.You can check it by
http://pypi.python.org/simple/<package name>
Because pip searches in this above url.If There is no download links, You have to add download_link as metadata.That is something like
in setup.py
setup(...,
download_url = 'http://pypi/path/to/package.tar.gz',
)
I found out, your's is
https://pypi.python.org/packages/source/i/i2cdev/i2cdev-1.2.4.tar.gz

Related

Does anyone know how to use letsum?

I am trying to do legal text summarization and found this open source package, but I don't know how to install and use it. I tried using pip install letsum but it's giving me an error.
ERROR: Could not find a version that satisfies the requirement letsum (from versions: none)
ERROR: No matching distribution found for letsum
Below is the github documentation, any ideas how to use it?
https://github.com/Law-AI/summarization
Thank you in advance
You can follow these steps:
Clone the repository:
git clone https://github.com/Law-AI/summarization.git
Install dependencies
pip install -r summarization/supervised/requirements.txt
Get to summarization/supervised/legal-specific/LetSum:
cd summarization/supervised/legal-specific/LetSum
Open your IDE in the current directory and you should be able to import letsum without any problem!

pip install package still not following dependency links

I'm having serious trouble with using setup.py to pip install my package which also has dependency links. I have read this answer and this one thoroughly and none of the answers including the accepted ones help.
Here is the setup.py for the package trying to install.
Basically, it reads the requirements.txt to fill install_requires and dependency_links, most of the rest of the code is boilerplate from cookie-cutter. requirements.txt has a private github repo in it which is causing the issues. e.g. git+https://${GITHUB_OAUTH_TOKEN}#github.com/jmerkow/pripy.git#egg=pripy
When I run pip install -r requirements.txt everything works great, it installs the private repository. However, if I try to install using pip install . --process-dependency-links, I get this error:
Could not find a version that satisfies the requirement pripy (from mypackage==<sha>) (from versions: )
No matching distribution found for pripy (from mypackage==<sha>)
If I take off the #egg=xxx from the link in requirements, the private repo package is completely ignored by pip install . but not by pip install -r requirements.txt.
I have confirmed that dependency_links contains 'git+https://<actual-token>#github.com/jmerkow/pripy.git#egg=pripy' and that install_requires includes 'pripy'
How do you get setup to properly Is this a problem with the sub-package? setup.py in that repo is done pretty much the same, except there are no private links.
Ugh, this always happens. I put in all the work to the question, then I figure it out myself.
The issue is two things, first, all dependeny_links need to have a version, second to pull the version from the requirements file properly you need to do some magic on the string.
Comparing to the above setup.py, I changes the way requirements are added to the two lists (updated here). Then add the version to #egg=xxx on the link e.g.
git+https://${GITHUB_OAUTH_TOKEN}#github.com/jmerkow/pripy.git#egg=pripy-0.
Now setup.py will parse that file, take the egg version info, convert it to a pip version (basically replace the first '-' with an '==') for the install_requires, and you're good to go.

Why wouldn't this project I published to PyPI install with pip?

I've published a project to PyPI for the first time (https://pypi.org/project/xontrib-autojump/). But I get the following error when I try to install the project with this pip command:
$ pip install xontrib-autojump --user
Collecting xontrib-autojump
Could not find a version that satisfies the requirement xontrib-autojump (from versions: 0.1.linux-x86_64, 0.2.linux-x86_64, 0.3.linux-x86_64, 0.4.linux-x86_64)
No matching distribution found for xontrib-autojump
This project does appear when I run pip search xontrib-autojump:
$ pip search xontrib-autojump
xontrib-autojump (0.4) - autojump support for xonsh
...
Why can't I install this package with pip?
There are a number of possible problem areas - the main one is that it looks to me that you have not followed the naming convention needed to specify which python version the download is suitable for.
It is also a very good idea to set the metadata as this assist with finding packages.
The Packaging Tutorial is very helpful on this. It is also recommend that you test the upload and install process using the test instance of pypi.
The other big problem st that you "package" does not contain any python code and is not a python package in any way shape or form.

Can't figure out how to install Python package decoder.py

Python n00b here trying to install decoder.py via pip.
I see it exists when I search for it
$ pip search decoder.py
decoder.py (1.5XB) - Cross-platform Python module for decoding compressed audio files
But i can't seem to install it.
$ pip install decoder.py
Collecting decoder.py
Could not find a version that satisfies the requirement decoder.py (from versions: )
No matching distribution found for decoder.py
$ pip install decoder.py==1.5XB
Collecting decoder.py==1.5XB
Could not find a version that satisfies the requirement decoder.py==1.5XB (from versions: )
No matching distribution found for decoder.py==1.5XB
Any ideas?
This package doesn't provide any downloadable source code on PyPI.
You can download it from http://www.brailleweb.com/cgi-bin/python.py (this link was provided by authors on pypi, proceed with caution).
Author of decoder.py here. :D
I am sorry for inconvenience. pip was able to grab decoder.py from brailleweb.com before. It was unable to install it though because I didn't provide a setup script. I didn't do it primarily because people might like to choose which external decoders they would like to use and perhaps don't want to install them into their's Python site-packages directory on Windows.
So I settled for manual installation instead. You aren't first who complained about it and that's why next version will have the setup script at least.
The new version is coming out soon. I am sorry to say development is slower than I anticipated but new version will be ready sooner or later. :D
Cheers!

How to state in requirements.txt a direct github source

I've installed a library using the command
pip install git+git://github.com/mozilla/elasticutils.git
which installs it directly from a Github repository. This works fine and I want to have that dependency in my requirements.txt. I've looked at other tickets like this but that didn't solve my problem. If I put something like
-f git+git://github.com/mozilla/elasticutils.git
elasticutils==0.7.dev
in the requirements.txt file, a pip install -r requirements.txt results in the following output:
Downloading/unpacking elasticutils==0.7.dev (from -r requirements.txt (line 20))
Could not find a version that satisfies the requirement elasticutils==0.7.dev (from -r requirements.txt (line 20)) (from versions: )
No distributions matching the version for elasticutils==0.7.dev (from -r requirements.txt (line 20))
The documentation of the requirements file does not mention links using the git+git protocol specifier, so maybe this is just not supported.
Does anybody have a solution for my problem?
Normally your requirements.txt file would look something like this:
package-one==1.9.4
package-two==3.7.1
package-three==1.0.1
...
To specify a Github repo, you do not need the package-name== convention.
The examples below update package-two using a GitHub repo. The text between # and # denotes the specifics of the package.
Specify commit hash (41b95ec in the context of updated requirements.txt):
package-one==1.9.4
git+https://github.com/path/to/package-two#41b95ec#egg=package-two
package-three==1.0.1
Specify branch name (master):
git+https://github.com/path/to/package-two#master#egg=package-two
Specify tag (0.1):
git+https://github.com/path/to/package-two#0.1#egg=package-two
Specify release (3.7.1):
git+https://github.com/path/to/package-two#releases/tag/v3.7.1#egg=package-two
Note that #egg=package-two is not a comment here, it is to explicitly state the package name
This blog post has some more discussion on the topic.
“Editable” packages syntax can be used in requirements.txt to import packages from a variety of VCS (git, hg, bzr, svn):
-e git://github.com/mozilla/elasticutils.git#egg=elasticutils
Also, it is possible to point to particular commit:
-e git://github.com/mozilla/elasticutils.git#000b14389171a9f0d7d713466b32bc649b0bed8e#egg=elasticutils
requirements.txt allows the following ways of specifying a dependency on a package in a git repository as of pip 7.0:1
[-e] git+git://git.myproject.org/SomeProject#egg=SomeProject
[-e] git+https://git.myproject.org/SomeProject#egg=SomeProject
[-e] git+ssh://git.myproject.org/SomeProject#egg=SomeProject
-e git+git#git.myproject.org:SomeProject#egg=SomeProject (deprecated as of Jan 2020)
For Github that means you can do (notice the omitted -e):
git+git://github.com/mozilla/elasticutils.git#egg=elasticutils
Why the extra answer?
I got somewhat confused by the -e flag in the other answers so here's my clarification:
The -e or --editable flag means that the package is installed in <venv path>/src/SomeProject and thus not in the deeply buried <venv path>/lib/pythonX.X/site-packages/SomeProject it would otherwise be placed in.2
Documentation
1 https://pip.readthedocs.org/en/stable/reference/pip_install/#git
2 https://pip.readthedocs.org/en/stable/reference/pip_install/#vcs-support
First, install with git+git or git+https, in any way you know. Example of installing kronok's branch of the brabeion project:
pip install -e git+https://github.com/kronok/brabeion.git#12efe6aa06b85ae5ff725d3033e38f624e0a616f#egg=brabeion
Second, use pip freeze > requirements.txt to get the right thing in your requirements.txt. In this case, you will get
-e git+https://github.com/kronok/brabeion.git#12efe6aa06b85ae5ff725d3033e38f624e0a616f#egg=brabeion-master
Third, test the result:
pip uninstall brabeion
pip install -r requirements.txt
Since pip v1.5, (released Jan 1 2014: CHANGELOG, PR) you may also specify a subdirectory of a git repo to contain your module. The syntax looks like this:
pip install -e git+https://git.repo/some_repo.git#egg=my_subdir_pkg&subdirectory=my_subdir_pkg # install a python package from a repo subdirectory
Note: As a pip module author, ideally you'd probably want to publish your module in it's own top-level repo if you can. Yet this feature is helpful for some pre-existing repos that contain python modules in subdirectories. You might be forced to install them this way if they are not published to pypi too.
None of these answers worked for me. The only thing that worked was:
git+https://github.com/path_to_my_project.git
No "e", no double "git" and no previous installs necessary.
Github has zip endpoints that in my opinion are preferable to using the git protocol. The advantages are:
You don't have to specify #egg=<project name>
Git doesn't need to be installed in your environment, which is nice for containerized environments
It works much better with pip hashing and caching
The URL structure is easier to remember and more discoverable
You usually want requirements.txt entries to look like this, e.g. without the -e prefix:
https://github.com/org/package/archive/1a58aa586efd4bca37f2cfb9d9348958986aab6c.tar.gz
To install from main branch:
https://github.com/org/package/archive/main.tar.gz
There is also an equivalent .zip endpoint, but it was reported in a comment that always using the .tar.gz endpoint avoids problems with unicode package names.
It seems like this is also a valid format:
gym-tictactoe # git+https://github.com/haje01/gym-tictactoe.git#84e22fc28fe192ba0040bdd56a697f63d3d4a3d5
If you do a pip install "git+https://github.com/haje01/gym-tictactoe.git", then look at what got installed by running pip freeze, you will see the package described in this format and can copy and paste into requirements.txt.
I'm finding that it's kind of tricky to get pip3 (v9.0.1, as installed by Ubuntu 18.04's package manager) to actually install the thing I tell it to install. I'm posting this answer to save anyone's time who runs into this problem.
Putting this into a requirements.txt file failed:
git+git://github.com/myname/myrepo.git#my-branch#egg=eggname
By "failed" I mean that while it downloaded the code from Git, it ended up installing the original version of the code, as found on PyPi, instead of the code in the repo on that branch.
However, installing the commmit instead of the branch name works:
git+git://github.com/myname/myrepo.git#d27d07c9e862feb939e56d0df19d5733ea7b4f4d#egg=eggname
For private repositories, I found that these two work fine for me:
pip install https://${GITHUB_TOKEN}#github.com/owner/repo/archive/main.tar.gz
Where main.tar.gz refers to the main branch of your repo and can be replaced with other branch names. For more information and using the more recent Github API see here:
pip install https://${GITHUB_TOKEN}#api.github.com/repos/owner/repo/tarball/master
If you have git installed and available, then
pip install git+https://${GITHUB_TOKEN}#github.com/owner/repo.git#main
achieves the same, and it also allows for some more flexibility by appending #branch or #tag or #commit-hash. That approach, however, actually clones the repo into a local temp folder which can take a noticeable amount of time.
You can use the URLs in your requirements.txt, too.

Categories