本地 Pip 安装无法在包中导入任何 类

Local Pip install not able to import any classes within the package

我有一个 python 包,是我从

构建的
python setup.py sdist

包名是:Yify

我使用

安装了这个
pip3 install . 

在此之后,当我打开 python3 解释器和 import Yify 时,它导入成功但它似乎没有在 [=42= 中包含主 python 文件] 目录 。

这是文件夹结构:-

├── dist
│   └── Yify-1.0.tar.gz
├── get-pip.py
├── LICENSE
├── README.rst
├── requirements.txt
├── setup.cfg
├── setup.py
├── Yify
│   ├── __init__.py
│   ├── venv
|   ├── Yify.py

Yify.py 包含 yify class 。 当我做

import Yify
Yify.yify()

它给我 'yify' 未找到错误! .

如何解决?

这里是setup.py内容:-

import platform
from setuptools import setup

install_requires = ['bs4' , 'urllib3' ]


setup(
    name='Yify',
    packages = ['Yify'] ,
    version = 'v1.0',
    description = '''
    This Module is used to get the Top seeded torrents at any given time and get the entire movie details and ratings . 
    Its also useful to search for any movie using different parameters and obtain their magnet link or torrent file of any prefered quality.
''' ,
    author = 'Natesh M Bhat' ,
    url = 'https://github.com/nateshmbhat/Yify-Python',
    author_email = 'nateshmbhatofficial@gmail.com' ,
    # download_url = 'https://github.com/nateshmbhat/pyttsx3/archive/v2.6.tar.gz',
    keywords=['yify','torrent-python' , 'movie-torrent' , 'torrent' , 'pyyify' , 'Yify' , 'yify torrent' , 'yify download' , 'download yify' , 'yifyer'  , 'yifypy' , 'torrent download' , 'movie torrent' , 'movie downloader', 'movie finder'],
    classifiers = [] ,
    install_requires=install_requires
)

此外,当我直接进入 python3.6 distpackages/Yify 文件夹并从那里执行 python3 时。一切正常。

还有 dir(Yify) return 只有以下字段

dir(Yify)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
  1. __init__. 必须调用 __init__.py.

  2. 当您执行 import Yify 时,您只会导入 Yify/__init__.py,而不是 Yify/Yify.py,除非它是在 __init__.py 中导入的。

  3. 要修复您的导入,请执行:from Yify import Yify。这样你就真的导入了 Yify/Yify.py.