Python:如何编辑已安装的包? [英] Python: how to edit an installed package?

查看:42
本文介绍了Python:如何编辑已安装的包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过 pip install something 安装了一些包.我想编辑包 something 的源代码.它在哪里(在 ubuntu 12.04 上)以及如何在每次编辑源代码并运行它时重新加载它?

I installed some package via pip install something. I want to edit the source code for the package something. Where is it (on ubuntu 12.04) and how do I make it reload each time I edit the source code and run it?

目前我正在编辑源代码,然后一遍遍运行python setup.py,结果很麻烦.

Currently I am editing the source code, and then running python setup.py again and again, which turns out to be quite a hassle.

推荐答案

您不应该编辑已安装的包.相反,安装一个分叉版本的包.

You should never edit an installed package. Instead, install a forked version of package.

如果你需要经常编辑代码,不要通过pip install something安装包,并在'.../site_packages/...'中编辑代码

If you need to edit the code frequently, DO NOT install the package via pip install something and edit the code in '.../site_packages/...'

相反,将源代码放在开发目录下,并使用

Instead, put the source code under a development directory, and install it with

python setup.py develop
# or
pip install -e path/to/SomePackage
# Or use a vcs at the first place
$ pip install -e git+https://github.com/lakshmivyas/hyde.git#egg=hyde

将您的更改放在版本控制系统中,并告诉 pip 显式安装它.

Put your changes in a version control system, and tell pip to install it explicitly.

参考:编辑模式

这篇关于Python:如何编辑已安装的包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆