如何在本地安装Python包而不将其上载到PyPi
我知道以前有人问过这个问题,他们是关于这个主题的参考资料,但这些说明似乎都不起作用。我有一个名为PyFinancials的软件包,目录结构如下,我正在一台使用BigSur OS V11.1的Macintosh计算机上工作如何在本地安装Python包而不将其上载到PyPi,python,python-3.x,pip,Python,Python 3.x,Pip,我知道以前有人问过这个问题,他们是关于这个主题的参考资料,但这些说明似乎都不起作用。我有一个名为PyFinancials的软件包,目录结构如下,我正在一台使用BigSur OS V11.1的Macintosh计算机上工作 PyFinances |_PyFinances | |_ __init__.py | |_ finances.py |_ data |_ test |_ scripts |_ docs |_ README.rst |_ LICENSE |_ setup.py |_ Make
PyFinances
|_PyFinances
| |_ __init__.py
| |_ finances.py
|_ data
|_ test
|_ scripts
|_ docs
|_ README.rst
|_ LICENSE
|_ setup.py
|_ Makefile
|_ requirements.txt
|_ .venv
Makefile
包含以下内容
init:
pip3 install -r requirements.txt
test:
pytest -s test
并且setup.py
具有以下内容
# -*- coding: utf-8 -*-
# Learn more: https://github.com/kennethreitz/setup.py
from setuptools import setup, find_packages
with open('README.rst') as f:
readme = f.read()
with open('LICENSE') as f:
license = f.read()
setup(
name='PyFinances',
version='0.1.0',
description='develops a statistical estimate for the value of checking and savings account',
long_description=readme,
author='Jonathan A. Webb',
author_email='webbja123@gmail.com',
license=license,
packages=find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"Programming Languate :: Python :: 3.9",
"Operating System :: MacOS",
],
zip_safe=False,
)
我试图在本地系统上安装自己的代码作为包,而不将其上载到PyPi。我在一个虚拟环境中工作,在最上面的pyfinancials
目录中,首先使用以下命令安装wheel
pip3 install wheel
然后使用以下命令安装我的包
pip3 install .
安装程序向我显示消息
已成功安装PyFinances-0.10
,这使我认为一切正常。但是,如果我cd到一个完全不同的目录,打开Python命令行界面并键入import-PyFinances
,或者尝试使用使用相同命令的文件,我会得到一个modulenofounderror
。有人能告诉我将自己的Python代码转换为本地安装的过程有什么问题吗?经过大量调查,我发现我使用了错误的虚拟环境,这使我无法访问我的软件包。在更改为正确的.venv文件后,它修复了问题。在该venv
中执行pip列表时,您会得到什么?@astrochun它显示了虚拟环境中安装的所有软件包,包括PyFinancials 0.1.0版。我们都做到了!