简体   繁体   中英

How to install/uninstall/update a homemade Python module?

I wrote a small module that has this structure:

~/
   a/
      b/
         foo/
            __init__.py
            foo.py
            bar.py

Each time I use my module - I have to go in its folder and start my interactive session:

$ cd ~/a/b
$ ipython

In [0]: from foo import *

I would like to easily make available my module globally on my PC. Do I need to structure it as package with a setup.py and execute python setup.py install after each change on my module?

Another solution that I don't really like is adding the following to my ipython profile:

import sys
sys.path.append("~/a/b")

Or modifying my PYTHONPATH :

export PYTHONPATH=$PYTHONPATH:$HOME/a/b

是的,将其作为python软件包全局安装或使用virtualenv

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM