pip package error after uploading to test.pypi.org

Viewed 549

I have created a pip package as below

enter image description here

my setup.py file

import setuptools

with open('README.md') as f:
    long_description = f.read()

setuptools.setup(
    name="calculator_py",
    version="0.0.1",
    scripts=['scripts/calculate.py'],
    author="xxxxxxx",
    author_email="xxxx@gmail.com",
    description="",
    long_description=long_description,
    long_description_content_type='text/markdown',
    url="",
    license='MIT',
    classifiers=[
    'Development Status :: 5 - Production/Stable',
    'Programming Language :: Python',
    'Programming Language :: Python :: 2',
    'Programming Language :: Python :: 2.7',
    'Programming Language :: Python :: 3',
    'Programming Language :: Python :: 3.5',
    'Programming Language :: Python :: 3.6',
    'Programming Language :: Python :: 3.7',
    'Programming Language :: Python :: Implementation :: CPython',
    'Programming Language :: Python :: Implementation :: PyPy',
    'License :: OSI Approved :: MIT License',
    'Operating System :: OS Independent',

],
entry_points={
    'console_scripts': [
        'calculate=calculator.scripts.calculate:main',
    ],
}

)

I have uploaded this package to https://test.pypi.org

after I have installed package using

pip install -i https://test.pypi.org/simple/ calculator_py

I have checked package using

pip list

when I try to import this package it gives me below error

ModuleNotFoundError: No module named 'calculator_py'

calculate.py file

class calculate:

def __init__(self):
    pass

def add(self, arg1, arg2):
    return arg1 + arg2

def sub(self, arg1, arg2):
    return arg1 - arg2

def mul(self, arg1, arg2):
    return arg1 * arg2

def div(self, arg1, arg2):
    return arg1 / arg2

if __name__ == '__main__':
     calculate()

how can I solve this issue?

1 Answers

You probably need a packages=['scripts'] inside your setuptools.setup, eg.

setuptools.setup(
    ...
    packages=['scripts'],
    ...
)

Otherwise pip probably tries to guess it from name="calculator_py" and you don't have a package named calculator_py.

Related