Installing my project from testpypi gives me an error - python

I am learning how to package python projects and publish them and I ran into a problem I have been trying to solve ,but failed.
I have this small project and I am trying to upload it to Testpypi
I managed to upload it there and I can even find it at (https://test.pypi.org/project/cli-assistant/)
Problem: When I try to install it using
pip install -i https://test.pypi.org/simple/ cli-assistant
I get this error:
Looking in indexes: https://test.pypi.org/simple/
ERROR: Could not find a version that satisfies the requirement cli-assistant (from versions: none)
ERROR: No matching distribution found for cli-assistant
Here is the full setup.py file
from setuptools import setup, find_packages
with open("Description.rst", "r", encoding="utf-8") as fh:
long_description = fh.read()
with open("requirements.txt", "r", encoding="utf-8") as fh:
requirements = fh.read()
setup(
name= 'cli-assistant',
version= '0.0.5',
author= 'my name',
author_email= 'my email',
license= 'MIT License',
description='guide you with terminal and git commands',
long_description=long_description,
url='https://github.com/willsketch/Helper',
py_modules=[ 'my_helper'],
packages= find_packages(),
install_requires = [requirements],
classifiers=[
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
],
include_package_data=True,
package_data={'helper':['examples.txt']},
entry_points= {
'console_scripts':[
'helper = my_helper:cli',
]
}
)

You have uploaded only an .egg file. Pip cannot install eggs. You should upload a source distribution (.tar.gz or .zip) and/or a wheel (.whl).

Related

How to configure dependencies in Python package with pyproject.toml or setup.cfg? [duplicate]

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.

Install requirements based on users and their preferences (dynamic) in setup.py in python

I have implemented a code that install requirements using pip install command without any problem. In order not to install unnecessary packages for the user, it is required to ask them questions (input) and install the packages based on their answers.
Here is my current setup.py file which works perfect but install all packages:
setuptools.setup(
name="backbone",
version="1",
entry_points={
"console_scripts": [
'backbone_cli=backbone.backbone:main'
]
},
author="Mostafa Ghadimi",
author_email="<my_email>",
long_description=long_description,
long_description_content_type="text/markdown",
install_requires=requirements,
include_package_data=True,
url="https://github.com/mostafaghadimi/backbone",
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
packages=setuptools.find_packages(),
python_requires=">=3.6",
license='MIT',
)
As an example, let's imagine that we want to ask the user that whether he/she wants to install numpy or not. I have tried does_need_numpy = input('Do you want to install numpy? [y]es/[n]o') but it doesn't work and when I add it to setup.py, face to the following error while I want to install the package (pip install <package_name>):
File "/tmp/pip-req-build-ldgfq6l6/setup.py", line 11, in <module>
does_need_numpy = input('Do you want to install numpy? [y]es/[n]o')
EOFError: EOF when reading a line
As I have found, there is some functions like cmdclass install that may be the solution.
Can someone help me how to implement the expected functionality?
Thanks from #phd for his comment. As I have found there isn't any way to interactively install requirements based on user input using pip install command. So in order to satisfy the necessities, we have to use extras_require.
The problem was solved after adding extras_require as an argument in the setuptools.setup function.
setuptools.setup(
name="backbone",
version="1",
entry_points={
"console_scripts": [
'backbone_cli=backbone.backbone:main'
]
},
author="Mostafa Ghadimi",
author_email="<my_email>",
long_description=long_description,
long_description_content_type="text/markdown",
install_requires=requirements,
include_package_data=True,
url="https://github.com/mostafaghadimi/backbone",
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
packages=setuptools.find_packages(),
python_requires=">=3.6",
license='MIT',
extras_require={
'pandas_numpy': [
'numpy',
'pandas_numpy',
]
},
)
And it can be installed locally using the following command in virtual environment.
pip install git+https://$GITLAB_USERNAME:$GITLAB_PASSWORD#$GITLAB_URL[pandas_numpy]
For more information and find out the differences between install_requires and extras_require checkout this link.

install_requires in setup.py file of Python package errors [duplicate]

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.

python setup.py install missing dependencies

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.

Installing with pip breaks on python setup.py egg_info

I'm trying to install my own program via Pip and the PyPI with the usual command pip install tvrenamr however I'm getting the error below:
Downloading/unpacking tvrenamr
Running setup.py egg_info for package tvrenamr
Usage: tvr [options] <file/folder>
-c: error: no such option: --egg-base
Complete output from command python setup.py egg_info:
Usage: tvr [options] <file/folder>
-c: error: no such option: --egg-base
----------------------------------------
Command python setup.py egg_info failed with error code 2
Storing complete log in /Users/george/.pip/pip.log
It's been a while since I checked but I used to be able to pip install my code with the previous versions I put on the PyPI, however I updated to the latest Pip - not sure if would cause things to break or not!
So when pip is running python setup.py egg_info it seems that TvRenamr is being called, or at least my option parser class has been imported.
My setup.py:
from os.path import dirname, join
from setuptools import setup, find_packages
from tvrenamr import get_version
def fread(fname):
return open(join(dirname(__file__), fname)).read()
setup(
name = 'tvrenamr',
version = get_version(),
description = 'Rename tv show files using online databases',
long_description = fread('README.markdown'),
author = 'George Hickman',
author_email = 'george#ghickman.co.uk',
url = 'http://github.com/ghickman/tvrenamr',
license = 'MIT',
packages = find_packages(exclude=['tests']),
entry_points = {'console_scripts': ['tvr = tvrenamr.tvrenamr:run',],},
classifiers = [
'Environment :: Console',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: MIT License',
'Operating System :: MacOS',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.6',
'Topic :: Multimedia',
'Topic :: Utilities',
'Natural Language :: English'],
install_requires = ('lxml', 'pyyaml',)
)
tvrenamr/__init__.py:
__version__ = (3, 0, 0)
def get_version():
return '.'.join(map(str, __version__))
My only thoughts on how it's getting tvrenamr's options now are that either find_packages or the entry_points option are in some way importing tvrenamr.py and thus options.py??
All versions of TvRenamr were uploaded to the PyPI with python setup.py sdist upload.
I really am stumped with this problem - any help much appreciated!
EDIT: I can run python setup.py egg_info with no errors.
Unfortunately this was a case of setup tools masking an error in the setup.py that was being caused by a bad version string in tvrenamr/__init__.py.
I picked up on the error after installing manually with python setup.py install into a clean virtualenv so something in my environment must have been affecting things before too.

Categories

Resources