简体   繁体   中英

setup.py find_packages() not installing packages to anaconda environment

if I run my setup.py file with python setup.py install from the anaconda enviroment env it does not install the packages.

Folder structure:

|setup.py
|package_name/
|---__init__.py
|---package_one.py
|---package_two.py

setup.py content:

from setuptools import setup, find_packages
setup(
    name='NAME',
    version='1.0',
    description="libraries",
    license="MIT",
    packages=find_packages(),
    author="Max",
    scripts={},
)

The package files contain each a class eg package_one.py

class class_one():
    def __init__(self, root_path, project_path):
        self.root_path = root_path
        self.project_path = project_path
        self.project = Project()
        self.hostname = os.environ['COMPUTERNAME']

after running setup.py I can't import any package with from package_name.package_one import class_one what am I missing?

I cant import any package with from package_name.package_one import class_one

This will only work if your current working directory is root folder of the project, in this case the parent folder which contains /package_name . Otherwise, it will give ModuleNotFoundError .

You can try the approach below. This specifies which packages to include, but also the use of package_name separately includes the files in the base of the directory.

from setuptools import setup, find_packages
setup(
    name='NAME',
    version='1.0',
    description="libraries",
    license="MIT",
    packages=find_packages(include=['package_name', 'package_name.*']),
    author="Max",
    scripts={},
)

Read this for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM