我有一个我用
构建的python包python setup.py sdist
包名是:Yify
我使用
安装了它pip3 install .
在此之后,当我打开python3解释器和import Yify
时,它成功导入,但它似乎不包含dist_packages / Yify目录中的主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
类。
当我做的时候
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)也只返回以下字段
dir(Yify)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
答案 0 :(得分:0)
__init__.
必须被称为__init__.py
。
当您执行import Yify
时,除Yify/__init__.py
导入Yify/Yify.py
外,您才会导入__init__.py
,而不是from Yify import Yify
。
要修复导入操作:Yify/Yify.py
。这样你就可以真正导入install create logical_path:program.exe/header
。