I try to install my python package using:
python setup.py install
My setup.py looks like this:
import os
from setuptools import setup, find_packages
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, 'README.txt')) as f:
README = f.read()
with open(os.path.join(here, 'CHANGES.txt')) as f:
CHANGES = f.read()
requires = [
'pyramid',
'pyramid_chameleon',
'pyramid_debugtoolbar',
'mysql-python',
'SQLAlchemy',
'transaction',
'zope.sqlalchemy',
'waitress',
'pyramid_tm',
'simplejson',
'webtest',
'mock', 'pyopenms'
]
setup(name='mypackage',
version='0.1',
description='mypackage',
long_description=README + '\n\n' + CHANGES,
classifiers=[
"Programming Language :: Python",
"Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
],
author='',
author_email='',
url='',
keywords='web wsgi bfg pylons pyramid',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
test_suite='mypackage_test',
install_requires=[],
entry_points="""\
[paste.app_factory]
main = mypackage:main
[console_scripts]
initialize_mypackage_db = mypackage.scripts.initializedb:main
""",
)
My problem is that although mysql-python is installed. It tries to install MySQLdb as a package. It looks like it scans all files for used packages and tries to install them. However this is not possible since there is no package with the name MySQLdb only mysql-python.
Here is the error i receive:
creating /usr/local/lib/python2.7/dist-packages/mypackage-0.1-py2.7.egg
Extracting mypackage-0.1-py2.7.egg to /usr/local/lib/python2.7/dist-packages
Removing mypackage 0.1 from easy-install.pth file
Adding mypackage 0.1 to easy-install.pth file
Installing initialize_mypackage_db script to /usr/local/bin
Installed /usr/local/lib/python2.7/dist-packages/mypackage-0.1-py2.7.egg
Processing dependencies for mypackage==0.1
Searching for MySQLdb
Reading https://pypi.python.org/simple/MySQLdb/
No local packages or working download links found for MySQLdb
error: Could not find suitable distribution for Requirement.parse('MySQLdb')
If I use pip install .
I get basically the same error:
Collecting MySQLdb (from mypackage==0.1)
/Users/Backert/ligandomat_env/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/Users/Backert/ligandomat_env/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Could not find a version that satisfies the requirement MySQLdb (from mypackage==0.1) (from versions: )
No matching distribution found for MySQLdb (from mypackage==0.1)
The MySQLdb package seems to be found as requirement in other python files, which are part of the projekt. I import the package there as import MySQLdb.
Related
I'm trying to create my first python package. To not bungle the whole deal, I've been attempting to upload it to the testpypi servers. That seems to go fine (sdist creates and upload doesn't show any errors). However, when I try to install it to a new virtualenv from https://testpypi.python.org/pypi, it complains about my install requirements, e.g.:
pip install -i https://testpypi.python.org/pypi poirot
Collecting poirot
Downloading https://testpypi.python.org/packages/source/p/poirot/poirot-0.0.15.tar.gz
Collecting tqdm==3.4.0 (from poirot)
Could not find a version that satisfies the requirement tqdm==3.4.0 (from poirot) (from versions: )
No matching distribution found for tqdm==3.4.0 (from poirot)
tqdm and Jinja2 are my only requirements. I tried specifying the versions, not specifying—error each way.
It appears that it's trying to find tqdm and Jinja2 on the testpypi server and not finding them (because they're only available at regular pypi). Uploading the package to the non-test server and running pip install worked.
What do I need to add to the setup.py file (below) to get it to find the requirements when uploaded to testpypi?
Thanks!
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
setup(name='poirot',
version='0.0.15',
description="Search a git repository's revision history for text patterns.",
url='https://github.com/dcgov/poirot',
license='https://raw.githubusercontent.com/DCgov/poirot/master/LICENSE.md',
packages=['poirot'],
install_requires=['tqdm==3.4.0', 'Jinja2==2.8'],
test_suite='nose.collector',
tests_require=['nose-progressive'],
classifiers=[
'Environment :: Console',
'Intended Audience :: Developers',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5'
],
include_package_data=True,
scripts=['bin/big-grey-cells', 'bin/little-grey-cells'],
zip_safe=False)
Update
PyPI has upgraded its site. According to the docs, the new advice is:
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple poirot
--index-url points to your package on TestPyPI.
--extra-index-url points to dependencies on PyPI.
poirot is your package.
Caution: despite this recommendation from the official docs, using --extra-index-url can be unsafe in certain situations, particularly on private servers. See also A. Sottile's video demonstrating the risks related to option ordering and mixing public with private PyPI servers. Use with caution and assess your own risks.
Out-dated
Try pip install --extra-index-url https://testpypi.python.org/pypi poirot.
See also a reference post.
Trying in Jan 2021, the update in the accepted answer didn't work for me. This worked:
pip install -i https://test.pypi.org/pypi/ --extra-index-url https://pypi.org/simple <your_package_in_testpypi>
Note that the first URL is test.pypi.org/pypi, and the second is pypi.org/simple.
Their official page should be updated, its instruction shows:
pip install -i https://test.pypi.org/simple/ <your_package_in_testpypi>
which does not work.
I'm trying to create my first python package. To not bungle the whole deal, I've been attempting to upload it to the testpypi servers. That seems to go fine (sdist creates and upload doesn't show any errors). However, when I try to install it to a new virtualenv from https://testpypi.python.org/pypi, it complains about my install requirements, e.g.:
pip install -i https://testpypi.python.org/pypi poirot
Collecting poirot
Downloading https://testpypi.python.org/packages/source/p/poirot/poirot-0.0.15.tar.gz
Collecting tqdm==3.4.0 (from poirot)
Could not find a version that satisfies the requirement tqdm==3.4.0 (from poirot) (from versions: )
No matching distribution found for tqdm==3.4.0 (from poirot)
tqdm and Jinja2 are my only requirements. I tried specifying the versions, not specifying—error each way.
It appears that it's trying to find tqdm and Jinja2 on the testpypi server and not finding them (because they're only available at regular pypi). Uploading the package to the non-test server and running pip install worked.
What do I need to add to the setup.py file (below) to get it to find the requirements when uploaded to testpypi?
Thanks!
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
setup(name='poirot',
version='0.0.15',
description="Search a git repository's revision history for text patterns.",
url='https://github.com/dcgov/poirot',
license='https://raw.githubusercontent.com/DCgov/poirot/master/LICENSE.md',
packages=['poirot'],
install_requires=['tqdm==3.4.0', 'Jinja2==2.8'],
test_suite='nose.collector',
tests_require=['nose-progressive'],
classifiers=[
'Environment :: Console',
'Intended Audience :: Developers',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5'
],
include_package_data=True,
scripts=['bin/big-grey-cells', 'bin/little-grey-cells'],
zip_safe=False)
Update
PyPI has upgraded its site. According to the docs, the new advice is:
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple poirot
--index-url points to your package on TestPyPI.
--extra-index-url points to dependencies on PyPI.
poirot is your package.
Caution: despite this recommendation from the official docs, using --extra-index-url can be unsafe in certain situations, particularly on private servers. See also A. Sottile's video demonstrating the risks related to option ordering and mixing public with private PyPI servers. Use with caution and assess your own risks.
Out-dated
Try pip install --extra-index-url https://testpypi.python.org/pypi poirot.
See also a reference post.
Trying in Jan 2021, the update in the accepted answer didn't work for me. This worked:
pip install -i https://test.pypi.org/pypi/ --extra-index-url https://pypi.org/simple <your_package_in_testpypi>
Note that the first URL is test.pypi.org/pypi, and the second is pypi.org/simple.
Their official page should be updated, its instruction shows:
pip install -i https://test.pypi.org/simple/ <your_package_in_testpypi>
which does not work.
This question already has answers here:
Pip install from pypi works, but from testpypi fails (cannot find requirements)
(2 answers)
Closed 2 years ago.
I am building a Python package and my package has some install requirements. This is my setup.py file code:
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="simpleEDA",
version="0.0.1",
author="Muhammad Shahid Sharif",
author_email="chshahidhamdam#gmail.com",
description="A wrapper around Pandas to perform Simple EDA with less code.",
long_description=long_description,
long_description_content_type="text/markdown",
url="github link here",
packages=['simple_eda'],
install_requires = ['matplotlib',
'numpy',
'numpydoc',
'pandas',
'scikit-image',
'scikit-learn',
'scipy',
'seaborn'],
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independen.t",
],
python_requires='>=3.5',
)
I have created the whl file and uploaded it on test PyPI. here is the link
pip install -i https://test.pypi.org/simple/ simpleEDA==0.0.1
If I try to install it, it gives me this error.
Could not find a version that satisfies the requirement numpydoc (from simpleEDA==0.0.1) (from versions: )
No matching distribution found for numpydoc (from simpleEDA==0.0.1)
Why is my install_requires is not working? Why it is not installing libraries?
You're attempting to install using TestPyPI as the index:
pip install -i https://test.pypi.org/simple/ simpleEDA==0.0.1
However most of your subdependencies don't exist on TestPyPI, for example https://test.pypi.org/project/numpydoc/ is 404.
Depending on what you're using TestPyPI for, you might be better off making a pre-release on PyPI instead.
I'm trying to install my package using pip from github repository. All actions i do in venv (w/ --no-site-packages).
In package i use pbr. I can't install one of my requirements that located in private repository (i use ssh link), i'm getting strange message:
Requirement already satisfied: python>=lpcclient in
/usr/lib/python2.7/lib-dynload (from ansible-lpc-
modules==0.0.1.dev168)
setup.py:
from setuptools import setup
setup(setup_requires=['pbr>=1.8'], pbr=True)
setup.cfg:
[metadata]
name = ansible-lpc-modules
author = Petr
version = 0.0.1
classifier =
Environment :: OpenStack
Intended Audience :: Information Technology
Intended Audience :: System Administrators
Development Status :: In Progress
Operating System :: POSIX :: Linux
Programming Language :: Python
Programming Language :: Python :: 2.7
[pbr]
skip_authors = True
skip_changelog = True
[files]
packages =
ansible/modules/lpc_mdls
ansible/module_utils/lpc_utils
requirements.txt:
ansible
-e git+ssh://git#git.lpc.org/vpc/python-lpcclient.git#develop#egg=python-lpcclient
What i do wrong? I don't have 'lpcclient' installed globally.
I am using python version 2.7 and pip version is 1.5.6.
I want to install extra libraries from url like a git repo on setup.py is being installed.
I was putting extras in install_requires parameter in setup.py. This means, my library requires extra libraries and they must also be installed.
...
install_requires=[
"Django",
....
],
...
But urls like git repos are not valid string in install_requires in setup.py. Assume that, I want to install a library from github. I have searched about that issue and I found something which I can put libraries such that in dependency_links in setup.py. But that still doesn't work. Here is my dependency links definition;
dependency_links=[
"https://github.com/.../tarball/master/#egg=1.0.0",
"https://github.com/.../tarball/master#egg=0.9.3",
],
The links are valid. I can download them from a internet browser with these urls. These extra libraries are still not installed with my setting up. I also tried --process-dependency-links parameter to force pip. But result is same. I take no error when pipping.
After installation, I see no library in pip freeze result in dependency_links.
How can I make them to be downloaded with my setup.py installation?
Edited:
Here is my complete setup.py
from setuptools import setup
try:
long_description = open('README.md').read()
except IOError:
long_description = ''
setup(
name='esef-sso',
version='1.0.0.0',
description='',
url='https://github.com/egemsoft/esef-sso.git',
keywords=["django", "egemsoft", "sso", "esefsso"],
install_requires=[
"Django",
"webservices",
"requests",
"esef-auth==1.0.0.0",
"django-simple-sso==0.9.3"
],
dependency_links=[
"https://github.com/egemsoft/esef-auth/tarball/master/#egg=1.0.0.0",
"https://github.com/egemsoft/django-simple-sso/tarball/master#egg=0.9.3",
],
packages=[
'esef_sso_client',
'esef_sso_client.models',
'esef_sso_server',
'esef_sso_server.models',
],
include_package_data=True,
zip_safe=False,
platforms=['any'],
)
Edited 2:
Here is pip log;
Downloading/unpacking esef-auth==1.0.0.0 (from esef-sso==1.0.0.0)
Getting page https://pypi.python.org/simple/esef-auth/
Could not fetch URL https://pypi.python.org/simple/esef-auth/: 404 Client Error: Not Found
Will skip URL https://pypi.python.org/simple/esef-auth/ when looking for download links for esef-auth==1.0.0.0 (from esef-sso==1.0.0.0)
Getting page https://pypi.python.org/simple/
URLs to search for versions for esef-auth==1.0.0.0 (from esef-sso==1.0.0.0):
* https://pypi.python.org/simple/esef-auth/1.0.0.0
* https://pypi.python.org/simple/esef-auth/
Getting page https://pypi.python.org/simple/esef-auth/1.0.0.0
Could not fetch URL https://pypi.python.org/simple/esef-auth/1.0.0.0: 404 Client Error: Not Found
Will skip URL https://pypi.python.org/simple/esef-auth/1.0.0.0 when looking for download links for esef-auth==1.0.0.0 (from esef-sso==1.0.0.0)
Getting page https://pypi.python.org/simple/esef-auth/
Could not fetch URL https://pypi.python.org/simple/esef-auth/: 404 Client Error: Not Found
Will skip URL https://pypi.python.org/simple/esef-auth/ when looking for download links for esef-auth==1.0.0.0 (from esef-sso==1.0.0.0)
Could not find any downloads that satisfy the requirement esef-auth==1.0.0.0 (from esef-sso==1.0.0.0)
Cleaning up...
Removing temporary dir /Users/ahmetdal/.virtualenvs/esef-sso-example/build...
No distributions at all found for esef-auth==1.0.0.0 (from esef-sso==1.0.0.0)
Exception information:
Traceback (most recent call last):
File "/Users/ahmetdal/.virtualenvs/esef-sso-example/lib/python2.7/site-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/Users/ahmetdal/.virtualenvs/esef-sso-example/lib/python2.7/site-packages/pip/commands/install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/Users/ahmetdal/.virtualenvs/esef-sso-example/lib/python2.7/site-packages/pip/req.py", line 1177, in prepare_files
url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
File "/Users/ahmetdal/.virtualenvs/esef-sso-example/lib/python2.7/site-packages/pip/index.py", line 277, in find_requirement
raise DistributionNotFound('No distributions at all found for %s' % req)
DistributionNotFound: No distributions at all found for esef-auth==1.0.0.0 (from esef-sso==1.0.0.0)
It seems, it does not use the sources in dependency_links.
The --process-dependency-links option to enable dependency_links was removed in Pip 19.0.
Instead, you can use a PEP 508 URL to specify your dependency, which is supported since Pip 18.1. Here's an example excerpt from setup.py:
install_requires=[
"numpy",
"package1 # git+https://github.com/user1/package1",
"package2 # git+https://github.com/user2/package2#branch1",
],
Note that Pip does not support installing packages with such dependencies from PyPI and in the future you will not be able to upload them to PyPI (see news entry for Pip 18.1).
Pip removed support for dependency_links a while back. The latest version of pip that supports dependency_links is 1.3.1, to install it
pip install pip==1.3.1
your dependency links should work at that point. Please note, that dependency_links were always the last resort for pip, ie. if a package with the same name exists on pypi it will be chosen over yours.
Note, https://github.com/pypa/pip/pull/1955 seems to start allowing dependency_links, pip kept it, but you might need to use some command line switches to use a newer version of pip.
EDIT: As of pip 7 ... they rethought dep links and have enabled them, even though they haven't removed the deprecation notice, from the discussions they seem to be here to stay. With pip>=7 here is how you can install things
pip install -e . --process-dependency-links --allow-all-external
Or add the following to a pip.conf, e.g. /etc/pip.conf
[install]
process-dependency-links = yes
allow-all-external = yes
trusted-host =
bitbucket.org
github.com
EDIT
A trick I have learnt is to bump up the version number to something really high to make sure that pip doesn't prefer the non dependency link version (if that is something you want). From the example above, make the dependency link look like:
"https://github.com/egemsoft/django-simple-sso/tarball/master#egg=999.0.0",
Also make sure the version either looks like the example or is the date version, any other versioning will make pip think its a dev version and wont install it.
You need to make sure you include the dependency in your install_requires too.
Here's an example setup.py
#!/usr/bin/env python
from setuptools import setup
setup(
name='foo',
version='0.0.1',
install_requires=[
'balog==0.0.7'
],
dependency_links=[
'https://github.com/balanced/balog/tarball/master#egg=balog-0.0.7'
]
)
Here's the issue with your example setup.py:
You're missing the egg name in the dependency links you setup.
You have
https://github.com/egemsoft/esef-auth/tarball/master/#egg=1.0.0.0
You need
https://github.com/egemsoft/esef-auth/tarball/master/#egg=esef-auth-1.0.0.0
I faced a similar situation where I want to use shapely as one of my package dependency. Shapely, however, has a caveat that if you are using windows, you have to use the .whl file from http://www.lfd.uci.edu/~gohlke/pythonlibs/. Otherwise, you have to install a C compiler, which is something I don't want. I want the user to simply use pip install mypackage instead of installing a bunch of other stuffs.
And if you have the typical setup with dependency_links
setup(
name = 'streettraffic',
packages = find_packages(), # this must be the same as the name above
version = '0.1',
description = 'A random test lib',
author = 'Costa Huang',
author_email = 'Costa.Huang#outlook.com',
install_requires=['Shapely==1.5.17'],
dependency_links = ['http://www.lfd.uci.edu/~gohlke/pythonlibs/ru4fxw3r/Shapely-1.5.17-cp36-cp36m-win_amd64.whl']
)
and run pip install ., it is simply going to pick the shapely on Pypi and cause trouble on Windows installation. After hours of researching, I found this link Force setuptools to use dependency_links to install mysqlclient and basically use from setuptools.command.install import install as _install to manually install shapely.
from setuptools.command.install import install as _install
from setuptools import setup, find_packages
import pip
class install(_install):
def run(self):
_install.do_egg_install(self)
# just go ahead and do it
pip.main(['install', 'http://localhost:81/Shapely-1.5.17-cp36-cp36m-win_amd64.whl'])
setup(
name = 'mypackage',
packages = find_packages(), # this must be the same as the name above
version = '0.1',
description = 'A random test lib',
author = 'Costa Huang',
author_email = 'test#outlook.com',
cmdclass={'install': install}
)
And the script works out nicely. Hope it helps.