推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
oh8
V2EX  ›  Python

关于 python 在 mac 下自定义模块目录的问题

  •  
  •   oh8 · Nov 3, 2016 · 4913 views
    This topic created in 3617 days ago, the information mentioned may be changed or developed.

    要如何在 terminal 的环境下添加自定目录?

    试着在 .profile 文件里面添加

    PYTHONPATH="/Users/xxxx/xxxx:$PYTHONPATH"
    export PYTHONPATH
    

    发现在 sublime text 里面可以正常运行,但在 terminal 下就报错 ImportError: No module named xxx

    最新版 mac , python2.7

    5 replies  •  2016-11-04 13:29:04 +08:00
    stamaimer
        1
    stamaimer  
       Nov 3, 2016 via iPhone
    import sys
    sys.path.append("path2module")
    v2014
        2
    v2014  
       Nov 3, 2016
    干嘛不把他打包,到处可以用
    写个 setup.py
    pip install -e .
    oh8
        3
    oh8  
    OP
       Nov 3, 2016
    @stamaimer
    这个确实可以解决问题,但感觉不太优雅啊。。

    @v2014
    因为导入的那个 py 文件也一直在改变
    lcj2class
        4
    lcj2class  
       Nov 3, 2016 via iPhone
    就是 2 楼说的方法, e 指定了是用开发者模式安装,会直接用源文件的
    oh8
        5
    oh8  
    OP
       Nov 4, 2016
    原来如此,谢了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5034 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 08:35 · PVG 16:35 · LAX 01:35 · JFK 04:35
    ♥ Do have faith in what you're doing.