Search code examples
pythonpypi

Unable to import python library that I created


For the past few hours, I've been trying to correctly upload a library to PyPI, but without success. I already managed to upload it to PyPI and even download it with pip, but always when I try to import it I get the following error:

    import pseudopython-org
                       ^
SyntaxError: invalid syntax

I already tried 2 different Youtube tutorials, running it on Ubuntu, on Google Collaboratory, but nothing seems to work. So, I believe it must be something either with my folder structure or the setup.py file.

My folder structure currently looks like this:

d-----        23/01/2022     22:36                dist
d-----        23/01/2022     22:41                pseudopython-org
d-----        23/01/2022     22:36                pseudopython_org.egg-info
-a----        23/01/2022     20:57             81 CHANGELOG.txt
-a----        23/01/2022     20:58           1061 LICENSE.txt
-a----        23/01/2022     20:58             25 MANIFEST.in
-a----        23/01/2022     21:54            369 README.md
-a----        23/01/2022     22:35            910 setup.py

Inside the pseudopython-org folder I have 2 files:

init.py

from py_to_pseudocode import python_to_pseudocode

py_to_pseudocode.py

def python_to_pseudocode(python_code):
    some logic
    return something

And my setup.py looks like this:

from setuptools import setup, find_packages


VERSION = '0.0.3'
DESCRIPTION = 'Converting Python code snippets to Pseudocode effectively.'
LONG_DESCRIPTION = 'Converting Python code snippets to Pseudocode effectively.'

# Setting up
setup(
    name="pseudopython-org",
    version=VERSION,
    author="anonymouscoolguy",
    author_email="<[email protected]>",
    description=DESCRIPTION,
    long_description_content_type="text/markdown",
    long_description=LONG_DESCRIPTION,
    packages=find_packages(),
    install_requires=[],
    keywords=['pseudocode', 'python'],
    classifiers=[
        "Development Status :: 1 - Planning",
        "Intended Audience :: Education",
        "Programming Language :: Python :: 3",
        "Operating System :: Unix",
        "Operating System :: MacOS :: MacOS X",
        "Operating System :: Microsoft :: Windows",
    ]
)

For a more detailed look at the files you can always download the repository in PyPI.

I have no clue what I'm doing wrong, and any input is greatly appreciated.

Thank you!


Solution

  • After some long hours and help from the community, I finally managed to solve the problem.

    Here is what I did:

    • Renamed my package to python2pseudocode so it won't have any '-', as suggested by Anthony in the comments.
    • Renamed the folder which contains the __init__.py file to the same as the package, as suggested by md2perpe
    • And finally, put all my code in the __init__.py file, so I won't have any mysterious imports.

    Thanks for all the help, greatly appreciated.