Python error “ImportError: No module named”

后端 未结 29 2965
野的像风
野的像风 2020-11-22 07:46

Python is installed in a local directory.

My directory tree looks like this:

(local directory)/site-packages/toolkit/interface.py

29条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 08:10

    If you are using a setup script/utility (e.g. setuptools) to deploy your package, don't forget to add the respective files/modules to the installer.


    When supported, use find_packages() or similar to automatically add new packages to the setup script. This will absolutely save you from a headache, especially if you put your project aside for some time and then add something later on.

    import setuptools
    
    setuptools.setup(
        name="example-pkg",
        version="0.0.1",
        author="Example Author",
        author_email="author@example.com",
        description="A small example package",
        packages=setuptools.find_packages(),
        classifiers=[
            "Programming Language :: Python :: 3",
            "Operating System :: OS Independent",
        ],
        python_requires='>=3.6',
    )
    

    (Example taken from setuptools documentation)

提交回复
热议问题