用setup.py从pip安装后出现模块未找到的错误

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

我的工作dir树结构。

├── LICENSE
├── MANIFEST.in
├── README.md
├── setup.py
└── spotidnldr
    ├── MANIFEST.in
    ├── README.md
    ├── __init__.py
    ├── __pycache__
    │   ├── __init__.cpython-38.pyc
    │   ├── converter.cpython-38.pyc
    │   ├── cover_download.cpython-38.pyc
    │   ├── downloader.cpython-38.pyc
    │   ├── env_checker.cpython-38.pyc
    │   ├── env_setup.cpython-38.pyc
    │   ├── spot.cpython-38.pyc
    │   ├── tag_embedder.cpython-38.pyc
    │   └── youtube_search.cpython-38.pyc
    ├── clifi.py
    ├── converter.py
    ├── cover_download.py
    ├── downloader.py
    ├── env_checker.py
    ├── env_setup.py
    ├── requirements.txt
    ├── spot.py
    ├── tag_embedder.py
    ├── termux_setup.sh
    ├── web.py
    └── youtube_search.py

现在当我使用setup.py安装时,即 pip install .程序成功安装,但问题是当我在setup.py中运行我在控制台脚本中指定的命令时,它抛出了一个ModuleNotFoundError.我的setup.py看起来是这样的。

import setuptools

with open("README.md", 'r+') as f:
    print("opened")
    long_de = f.read()


setuptools.setup(
    name="spotidnldr", # Replace with your own username
    version="0.1b1",
    author="Rohit Patil",
    author_email="[email protected]",
    description="the spotify song downloader",
    long_description = long_de,
    long_description_content_type="text/markdown",
    url="https://github.com/raprocks/spotindnldr",
    packages=["spotidnldr",],
    install_requires=[
        "spotipy",
        "youtube-dl",
        "eyeD3",
        "requests",
        "click",
        "ffmpeg-python",
    ],
    classifiers=[
        "Natural Language :: English",
        "Programming Language :: Python :: 3 :: Only",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
    ],
    entry_points='''
        [console_scripts]
        spoti=spotidnldr.clifi:download
    ''',
    python_requires='>=3.8',
    include_package_data=True,
)

在终端运行Spoti后出现错误

$ spoti
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/bin/spoti", line 5, in <module>
    from spotidnldr.clifi import download
  File "/data/data/com.termux/files/usr/lib/python3.8/site-packages/spotidnldr/clifi.py", line 2, in <module>
    from env_setup import *
ModuleNotFoundError: No module named 'env_setup'

请帮我解决这个问题。如果有帮助的话,我正在使用click python模块把我的应用程序变成一个cli。

python pip click setuptools setup.py
1个回答
0
投票

你正在调用来自 setup.py 在你的工作场所之外,名为 spotidnldr................................................................................................................................................................................................................................................ setup.py 会包含在你的根目录中。所以你必须使用

from spotidnldr.env_setup import *

希望对你有所帮助。

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