Thursday, 1 October 2020

Python Local Package Creation/Import Failing (Miserably)

I have a couple seemingly simple use cases that I feel like I'm missing a step on.

Basically, I have this project structure:

|- session_storage_base.py
|- aws_session_storage.py
|- README.md
|- setup.py

And here is setup.py:

import setuptools

with open("README.md", "r") as fh:
    long_description = fh.read()

setuptools.setup(
    name="session_data_access", 
    version="0.3",
    author="Colin",
    author_email="colin@asdf.com",
    description="session storage data access.",
    long_description=long_description,
    long_description_content_type="text/markdown",
    url="https://github.com/...",
    packages=setuptools.find_packages(),
    classifiers=[
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
    ],
    python_requires='>=3.6',
)    

I run the command:

python3 setup.py sdist bdist_wheel

...which successfully creates session_data_access-0.3.tar.gz.

I then run:

python3 -m pip install /Users/.../dist/session_data_access-0.3.tar.gz

...and when I follow-up with:

python3 -m pip list

...I see "session-data-access 0.0.3" among the listed packages.

When I run:

which python3

...the value is: "/Library/Frameworks/Python.framework/Versions/3.8/bin/python3".

I also set the Python interpreter in VS Code to make sure it's pointed to the above path.

However, when I do this:

import aws_session_storage

...VS Code has a squiggly line with the error: "Unable to import aws_session_storage".

If I cut & paste the files from my package into the project with the import statement, it works fine.

This is happening on EVERY bit of code I try to locally package.

Where exactly am I going wrong?!?



from Python Local Package Creation/Import Failing (Miserably)

No comments:

Post a Comment