尝试使用包时的ModuleNotFoundError

问题描述 投票:0回答:2

我们有一个在Windows 10上完美运行的自定义模块,然而,它在我们的Linux云实例(Debian Jessie)上出现了ModuleNotFoundError失败。文件夹结构如下:

|-dashboard-miner (git repo)
  |-setup.py
    |-dashboard_miner (the actual package)

我们的setup.py如下:

from setuptools import setup, find_packages
import dashboard_miner
import os

MODULE_BASEDIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'dashboard_miner')

try:
    long_description = open('README.md').read()
except IOError:
    long_description = ''

try:
    reqs = open(os.path.join(os.path.dirname(__file__), 'requirements.txt')).read()
except (IOError, OSError):
    reqs = ''

print(find_packages(where=MODULE_BASEDIR))

setup(
    name='dashboard_miner',
    version=dashboard_miner.get_version(short=True),
    description='Data mining utilities for True Cloud Dashboard',
    long_description=long_description,
    url='https://gitlabe1.ext.net.nokia.com/TCI/dashboard-miner',
    author='Hodossy, Szabolcs',
    author_email='[email protected]',
    license='NOKIA Confidential',
    packages=find_packages(where=MODULE_BASEDIR),
    package_dir={'': 'dashboard_miner'},
    install_requires=reqs,
    entry_points={
        'console_scripts': [
            'miner=dashboard_miner.cli:main',
        ]
    },
    zip_safe=False
)
python module importerror
2个回答
0
投票

检查dashboard_miner (the actual package)的文件结构/树,它必须包含一个init.py,以便它可以被Python识别为模块。


0
投票

实际上,事实证明find_packages函数返回相对路径,因此必须从适当的文件夹中调用它。

© www.soinside.com 2019 - 2024. All rights reserved.