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

查看:93
本文介绍了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天全站免登陆