1

I created my custom package and installed it by pip install -e ., but after I import mypackage, I cannot use any submodules of the package.

My file structure:

jjnutils
├─ jjnutils
    ├─ __init__.py
    ├─ myutil.py
    ├─ patch.py
├─ LICENSE
├─ README.md
├─ setup.py

__init__.py is empty. In my setup.py:


import setuptools

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

setuptools.setup(
    name="jjnutils", # Replace with your own username
    version="0.0.1",
    author="Jingnan",
    author_email="jiajingnan2222@gmail.com",
    description="A packages containing common utils functions",
    long_description=long_description,
    long_description_content_type="text/markdown",
    url="https://github.com/Ordgod/jjnutils",
    packages=setuptools.find_packages(),
    classifiers=[
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
    ],
    python_requires='>=3.6',
)

How do I install my custom package?

cd /home/jjnutils

pip install -e .

How do I use it?

In python internative ternamil: import jjnutils
It was successful.

jjnutils.patch.function()
It showed Error: AttributeError: module 'jjnutils' has no attribute 'patch'

dir(jjnutils)
It showed: ['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']

Could anyone tell me why???

Jingnan Jia
  • 1,108
  • 2
  • 12
  • 28

0 Answers0