使用 pip 安装单文件 python 模块
我想知道是否有一种方法可以使用 pip “安装”单文件 python 模块(即只需让 pip 下载文件的指定版本并将其复制到站点包)。
我有一个 Django 项目,它使用了几个不正确发行版的第 3 方模块(django-thumbs 和其他几个模块),并且我想 pip freeze
所有内容,以便该项目可以轻松安装在其他地方。我尝试过执行
pip install git+https://github.com/path/to/file.git
(也尝试使用 -e 标签),但 pip 抱怨没有设置。 py 文件。
编辑:我应该提到 - 我想这样做的原因是这样我可以将所需的模块包含在requirements.txt文件中,以便更轻松地在新机器或新的virtualenv上设置项目。
I'm wondering if there's a way to "install" single-file python modules using pip (i.e. just have pip download the specified version of the file and copy it to site-packages).
I have a Django project that uses several 3rd-party modules which aren't proper distributions (django-thumbs and a couple others) and I want to pip freeze
everything so the project can be easily installed elsewhere. I've tried just doing
pip install git+https://github.com/path/to/file.git
(and tried with the -e tag too) but pip complains that there's no setup.py file.
Edit: I should have mentioned - the reason I want to do this is so I can include the required module in a requirements.txt file, to make setting up the project on a new machine or new virtualenv easier.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
pip
需要有效的 setup.py 来安装 python 包。根据定义,每个 python 包都有一个 setup.py...您尝试安装的不是一个包,而是一个单个文件模块...这样做有什么问题:我不太明白想要背后的逻辑使用包管理器安装不是包的东西...
pip
requires a valid setup.py to install a python package. By definition every python package has a setup.py... What you are trying to install isn't a package but rather a single file module... what's wrong with doing something like:I don't quite understand the logic behind wanting to install something that isn't a package with a package manager...