如何运行此python脚本?

2024-06-16 15:07:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我是python新手,我想知道您是否可以帮我运行python脚本。我正在尝试从Github运行一个名为PunchBox的脚本:https://github.com/psav/punchbox。到目前为止,我已经有了Python3.9.5和GitBash

在GitHub页面中,它显示:

要安装,请将repo、cd克隆到其中,然后执行以下操作:

virtualenv -p python2 .pb2
source .pb2/bin/activate
pip install -U pip
pip install .

这到底是什么意思?在哪里运行此代码

到目前为止,我试着从GitHub下载zip文件,安装Python3.5.9,使用cmd,用cd查找目录,并运行代码;但有一个错误:

Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name punchbox was given, but was not able to be found.

error in punchbox setup command: Error parsing C:\Users\Mi\Downloads\punchbox-master\punchbox-master\setup.cfg: Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name punchbox was given, but was not able to be found.

还有一个requirements.txt,列出了所需的其他脚本:

pre-commit
click
mido
pbr
PyYAML
svgwrite

第一次运行脚本时是否自动安装

我有点困惑为什么我会出错。你知道我做错了什么吗

非常感谢你! 乔瓦尼


Tags: pipthetonameingithub脚本an
3条回答

@Giovanni T. 请参阅,您已经安装了Python并下载了GitHub存储库作为zip文件

pip install -r requirements.txt 只要运行这个命令

请确保目录指向存储此requirements.txt文件的文件夹

我想你是编程新手吧。您必须在终端中写入这些行

在Windows上,它是Command PromptPowerShell Applications(后者首选)。在macOS上,它是terminal

一次复制所有这些行,并将它们粘贴到首选终端。终端将自动一个接一个地运行这些程序

仅供参考:Venv是一个用于创建虚拟环境的python包。前面的命令用于设置环境。现在使用此命令而不是上一个命令(pip install .)安装所需的依赖项

pip install -r requirements.txt

根据您的评论,您的系统中似乎没有安装virtualenv。您可以使用命令pip install virtualenv安装它

现在,当您使用Windows计算机时,可以打开Command PromptWindows PowerShell窗口,并导航到克隆项目所在的目录。 现在,执行以下命令

virtualenv -p python2 .pb2
.pb2\Scripts\activate.bat
pip install -U pip
pip install -r requirements.txt

在虚拟环境(名为.pb2)中完成工作后,可以通过执行deactivate命令将其关闭

相关问题 更多 >