I am trying to build my own Python package (installable by pip) using the twine package. This is all going well right up until the point where I try to pip install my actual package (so after uploading to PyPi).
So I first run:
python3 setup.py sdist bdist_wheel
In which my setup.py install_requires list looks like this:
install_requires=[
'jupyter_kernel_gateway==2.4.0',
'pandas==1.0.2',
'numpy==1.18.1',
'azure-storage-blob==2.0.1',
'azure-datalake-store==0.0.48',
'psycopg2-binary==2.8.4',
'xlsxwriter==1.2.6',
'SQLAlchemy==1.3.12',
'geoalchemy2==0.6.3',
'tabulate==0.8.2',
'pyproj==1.9.6',
'geopandas==0.4.0',
'contextily==0.99.0',
'matplotlib==3.0.2',
'humanize==0.5.1',
'ujson==1.35',
'singleton-decorator==1.0.0',
'dataclasses==0.6',
'xlrd==1.2.0'],
In my understanding, these install_requires would be installed by pip when installing my own package.
After this I run
python3 -m twine upload --repository testpypi dist/*
To actually upload my package to PyPi. However, when pip installing my package, I get errors that say there are no versions that satisfy the requirements for a lot of the listed requirements. E.g.: ERROR: Could not find a version that satisfies the requirement psycopg2-binary==2.8.4
When I manually install these packages (e.g. pip install psycopg2-binary==2.8.4), they do get installed.
Is there any way to make the pip install of my package actually install the install_requires requirement list succesfully?
You didn't show how your pip install-ing your package, but I'm guessing you're using something like:
pip install your_project --index-url https://test.pypi.org/simple
The issue is that TestPyPI doesn't contain copies of your dependencies that exist on PyPI. For example:
Exists: https://pypi.org/project/psycopg2-binary/2.8.4/
Does not exist: https://test.pypi.org/project/psycopg2-binary/2.8.4/
You can configure pip to fall back on TestPyPI when a package is missing instead by specifying --extra-index-url instead:
pip install your_project --extra-index-url https://test.pypi.org/simple
Related
I want to have pip install my setup.py that contains a dependency locally modified for my needs that shares the same name as a package on PyPi, naturally pip goes for this one first.
Initially the setup I had was:
install_requires=[f'klvdata # file://{str(Path("localhost", Path.cwd(), "salt", "libs", "3rd_party", "klvdata-0.0.3-py3-none-any.whl"))}']
This pointed to my local copy and python setup.py install installs this no problem, pip on the other hand running pip install setup.py fails and looks to PyPi for the package.
My second attempt was modifying my install_requires and dependency_links keys with the following:
install_requires=['klvdata']
dependency_links=[str(Path("localhost", Path.cwd(), "salt", "libs", "3rd_party", "klvdata-0.0.3-py3-none-any.whl"))],
This fails as well for pip.
Is there something I'm missing?
I'm deploying some custom packages with pip straight from my company's private git repo (and it's awesome). But what if I want to install a specific version of my package?
This question completements Specify extras_require with pip install -e.
I'm trying to install it with:
pip install git+https://github.com/user/project.git#egg=project==0.0.1[extra]
But I get a ERROR: Invalid requirement: 'project==0.0.1[extra]' message.
Thanks!
Easy enough:
pip install git+https://github.com/user/project.git#v0.0.1#egg=project[extra]
Of course, assuming version 0.0.1 exists.
If your project is in a subfolder:
pip install "git+https://github.com/user/project.git#v0.0.1#egg=project[extra]&subdirectory=my_subprojects/subproject"
From the documentation
I have created an uploaded a package to PyPI. I have generated the requirements.txt file within the package too. How can I now ensure that when a user does pip install MyPackge, all its dependencies are also installed?
I decided to try to install pygame and have run into this problem:
Requirement 'pygame-1.9.3-cp37-cp37m-win32.whl' looks like a filename, but the file does not exist
pygame-1.9.3-cp37-cp37m-win32.whl is not a supported wheel on this platform.
Everything worked up till this point and I'm so close to installing pygame. Also this is the thing that I typed:
pip install pygame-1.9.3-cp37-cp37m-win32.whl
You normally use a tool like pip to install wheels. Leave it to the tool to discover and download the file if this is for a project hosted on PyPI.
For this to work, you do need to install the wheel package:
Pip install wheel
You can then tell pip to install the project (and it'll download the wheel if available), or the wheel file directly:
pip install project_name # discover, download and install
pip install wheel_file.whl # directly install the wheel
The wheel module, once installed, also is runnable from the command line, you can use this to install already-downloaded wheels:
python -m wheel install wheel_file.whl
Also see the wheel project documentation.
I am trying to install the ScientificPython package into a newly installed distribution of Python on a Fedora 14 x64 system. Pip finds ScientificPython in the repository but does not want to install it
[bin]$ sudo ./python2.7 ./pip search ScientificPython
ScientificPython - Various Python modules for scientific computing
[bin]$ sudo ./python2.7 ./pip install ScientificPython
Downloading/unpacking ScientificPython
Could not find any downloads that satisfy the requirement ScientificPython
No distributions at all found for ScientificPython
Storing complete log in /tmp/tmpDLdmjy
Why could this happen?
Thanks!
Have a look at the ScientificPython entry on pypi and you will find that it only contains a link to their project page, no downloadable package or egg (which pip would need to install from). That's why pip told you Could not find any downloads. You will have to install by hand following their instructions.
Bottom line: if pip search lists a given package that doesn't necessarily mean you can pip install it (in most cases you fortunately can).
This may due to the unverified files in the installation package . try with the
--allow-unverified
pip install package_name==version --allow-unverified package_name
example
pip install django-ajax-filtered-fields==0.5 --allow-unverified django-ajax-filtered-fields
The package name is actually scipy, not ScientificPython
Try:
pip install scipy