使用 pip 在本地安装 python 包

install python package locally with pip

我正在尝试按照 this tutorial 使用 pip 在本地安装 python 包。

我的结构是这样的:

bacnet-restful/
    example-node-red-flows/
    flask_version/
    images/
    swagger_json/
    scanning_scripts/
    modulepkg/
              __init__.py
              aioapp.py
              bacnet_actions.py
              models.py
              views.py
    .gitignore.txt
    LICENSE
    README
    requirements.txt
    runtime.txt
    setup.py

根据 bacnet-restful 目录中的教程,当我 运行 pip install wheel 出现此错误时:

WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages)
Requirement already satisfied: wheel in c:\python39\lib\site-packages (0.37.0)
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages)

也在 Windows。 Python 版本为 3.9.6

这是我的setup.py

import setuptools
 
with open("README.md", "r") as fh:
    long_description = fh.read()
 
setuptools.setup(
    name="bacnet-restful",
    version="0.0.1",
    author="author newb",
    author_email="newb.newb@gmail.com",
    description="restful BACnet App",
    long_description=long_description,
    long_description_content_type="text/markdown",
    packages=setuptools.find_packages(),
    classifiers=[
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
    ],
    python_requires='>=3.8',
)

编辑

PS C:\Desktop\bacnet-restful> pip install bacnet-restul
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages)
ERROR: Could not find a version that satisfies the requirement bacnet-restul (from versions: none)
ERROR: No matching distribution found for bacnet-restul
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages)

编辑 2

我得到了一些 python 3.9 的 tips here,关于 setup.py 应该如何安装软件包:

from distutils.core import setup

setup(name='bacnet-restful',
      version='1.0',
      description='Python Distribution Utilities',
      author='author newb',
      author_email='newb.newb@mail.com',
      url='https://www.python.org/',
      py_modules=['aiohttp', 'BAC0', 'aiohttp_pydantic'],
     )

请在您的 virtualenv 中尝试以下操作。

pip install wheel
pip install .