pypi安装后在pip安装上导入错误

时间:2019-06-13 17:48:14

标签: pip setup.py pypi

ref:https://github.com/louking/loutilities/tree/0.14.7

在此软件包的pip安装后,我收到importerror。当我使用easy_install的鸡蛋时,一切都很好。任何有关如何调试的帮助将不胜感激。

使用以下命令将此软件包安装到pypi,并使用“来自c:\ users \ lking \ anaconda2 \ lib \ site-packages \ pip(python 2.7)的pip 18.1”进行pip安装

python setup.py install
python setup.py sdist bdist_wheel
twine upload dist/loutilities-0.14.7.*
   :
# later
pip install loutilities

运行项目时,请参阅以下内容

NoAppException: While importing "run", an ImportError was raised:

Traceback (most recent call last):
  File "C:\Users\lking\Documents\Lou's Software\projects\contracts\contracts\venv\lib\site-packages\flask\cli.py", line 235, in locate_app
    __import__(module_name)
  File "C:\Users\lking\Documents\Lou's Software\projects\contracts\contracts\run.py", line 31, in <module>
    app = create_app(Development(configpath), configpath)
  File "C:\Users\lking\Documents\Lou's Software\projects\contracts\contracts\contracts\__init__.py", line 82, in create_app
    from contracts.views.frontend import bp as frontend
  File "C:\Users\lking\Documents\Lou's Software\projects\contracts\contracts\contracts\views\frontend\__init__.py", line 18, in <module>
    import frontend
  File "C:\Users\lking\Documents\Lou's Software\projects\contracts\contracts\contracts\views\frontend\frontend.py", line 21, in <module>
    from loutilities.flask_helpers.blueprints import add_url_rules
ImportError: No module named flask_helpers.blueprints

find_packages似乎正在找到适当的软件包:

from setuptools import find_packages
find_packages()
Out[4]: ['loutilities', 'tests', 'loutilities.flask_helpers']

setup.py:

#!/usr/bin/python
# [irrelevant comments deleted]

import glob
import pdb

# home grown
from loutilities import version

from setuptools import setup, find_packages

def globit(dir, filelist):
    outfiles = []
    for file in filelist:
        filepath = '{0}/{1}'.format(dir,file)
        gfilepath = glob.glob(filepath)
        for i in range(len(gfilepath)):
            f = gfilepath[i][len(dir)+1:]
            gfilepath[i] = '{0}/{1}'.format(dir,f)  # if on windows, need to replace backslash with frontslash
            outfiles += [gfilepath[i]]
    return (dir, outfiles)

setup(
    name = "loutilities",
    version = version.__version__,
    packages = find_packages(),
#    include_package_data = True,
    scripts = [
        'loutilities/agegrade.py',
        'loutilities/apikey.py',
        'loutilities/applytemplate.py',
        'loutilities/filtercsv.py',
        'loutilities/makerst.py',
    ],

    # Project uses reStructuredText, so ensure that the docutils get
    # installed or upgraded on the target machine
    install_requires = [
          'unicodecsv>=0.13.0',
        ],

    # If any package contains any of these file types, include them:
    data_files = ([
            globit('loutilities', ['*.conf','*.pyc','*.pyd','*.dll','*.h','*.xlsx']),
            globit('doc/source', ['*.txt', '*.rst', '*.html', '*.css', '*.js', '*.png', '*.py', ]),
            globit('doc/build/html', ['*.txt', '*.rst', '*.html', '*.css', '*.js', '*.png', ]),
            globit('doc/build/html/_sources', ['*.txt', '*.rst', '*.html', '*.css', '*.js', '*.png', ]),
            globit('doc/build/html/_static', ['*.txt', '*.rst', '*.html', '*.css', '*.js', '*.png', ]),
            globit('doc/build/html/_images', ['*.png', ]),
        ]),


    entry_points = {
        'console_scripts': [
            'agegrade = loutilities.agegrade:main',
            'apikey = loutilities.apikey:main',
            'applytemplate = loutilities.applytemplate:main',
            'filtercsv = loutilities.filtercsv:main',
            'makerst = loutilities.makerst:main',
        ],
    },


    zip_safe = False,

    # metadata for upload to PyPI
    description = 'some hopefully useful utilities',
    long_description=open("README.md").read(),
    license = 'Apache License, Version 2.0',
    author = 'Lou King',
    author_email = 'lking@pobox.com',
    url = 'http://github.com/louking/loutilities',
    # could also include long_description, download_url, classifiers, etc.
)

1 个答案:

答案 0 :(得分:1)

{} currentUserPermissions: (...) > get currentUserPermissions: f () > __proto__: Object 之后,我在虚拟环境的顶层看到一个未知目录pip install loutilities。该目录包含几个loutilities,但没有任何子目录。我怀疑*.pyc试图找到子目录import loutilities.flask_helpers并失败。

我认为顶层目录来自代码

loutilities/flask_helpers

我怀疑 globit('loutilities', ['*.conf','*.pyc','*.pyd','*.dll','*.h','*.xlsx']), 中存在一个错误,该错误将数据放置在错误的目录中。