[英]Pip package working locally but not if i install it via pipenv into another environment
I created a pypi package for an api to get the lessons from my school and uploaded it to pypi but when I install it, it doesn't get recognized. 我为api创建了一个pypi包,以便从学校上课,并将其上传到pypi,但是在安装时,它并没有被认可。 It works just fine locally when.
当它在本地工作正常。
I have tried deleting some lines from the startup.py like modules: []
but it doesn't seem to change anything and still works locally just fine 我试过从startup.py中删除一些行,例如
modules: []
但似乎没有任何改变,仍然可以在本地工作
setup.py setup.py
from setuptools import setup
with open("README.md", "r") as fh:
long_description = fh.read()
setup(
name="zermelo.py",
version="1.0.0",
license="MIT",
url="https://github.com/wouter173/zermelo.py",
description="Zermelo api wrapper library for python.",
long_description=long_description,
long_description_content_type="text/markdown",
package_dir={"zermelo": "zermelo"},
install_requires=["requests>=2.17.0"],
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Operating System :: OS Independent",
"License :: OSI Approved :: MIT License",
"Development Status :: 5 - Production/Stable",
]
)
Below is my file hierarchy: 以下是我的文件层次结构:
The source code is put into a __init__
file like this: 像这样将源代码放入
__init__
文件中:
from .client import Client
and in the .client
file which is client.py
I have a class called Client
with some functions but I don't think this has anything to do with it as it works just fine locally 在
.client
client.py
的.client
文件中,我有一个名为Client
的类,其中包含一些功能,但我认为这与它没有任何关系,因为它在本地可以正常工作
I try to import the package into a project like this: 我尝试将包导入到这样的项目中:
from zermelo import Client
Which works locally but not in a pipenv. 它在本地工作,但在pipenv中不起作用。
These are the commands I use to upload the package to pypi: 这些是我用来将软件包上传到pypi的命令:
python setup.py sdist
python setup.py bdist_wheel sdist
twine upload dist/*
and this is how I use my pipenv: 这就是我使用pipenv的方式:
pipenv --python 3.7
pipenv install zermelo.py
pipenv shell
python
>>> from zermelo import Client
But again that does not work and I have no idea why. 但这又是行不通的,我也不知道为什么。
When I import it in pipenv: 当我在pipenv中导入它时:
from zermelo import Client
It gives returns an Error: 它给出返回错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'zermelo'
I have tried putting different names and capitalizing zermelo but nothing works to import Client from zermelo but locally 我尝试使用不同的名称并大写zermelo,但是从zermelo导入客户端却无济于事
from zermelo import Client
works the way I want to it returns the Client from the init .py file. 以我想要的方式工作,它从init .py文件返回客户端。
Your setup.py
lists nothing to install. 您的
setup.py
没有列出任何要安装的内容。 You must use packages=<a list of packages>
or py_modules=<a list of .py modules>
. 您必须使用
packages=<a list of packages>
或py_modules=<a list of .py modules>
。
See https://packaging.python.org/tutorials/packaging-projects/ 参见https://packaging.python.org/tutorials/packaging-projects/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.