V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
saximi
V2EX  ›  Python

请问 Python 的包是装在什么目录下

  •  
  •   saximi · 2018-03-21 22:18:15 +08:00 · 4775 次点击
    这是一个创建于 2199 天前的主题,其中的信息可能已经有所发展或是发生改变。
    想从一台机器上安装好的 python 里把包拷贝出来到另外一台机器,请问包是默认装在 python 的什么路径下呢,感谢!
    10 条回复    2018-03-28 19:49:54 +08:00
    pimin
        1
    pimin  
       2018-03-21 22:26:36 +08:00 via iPad   ❤️ 1
    1.为了避免各种乱七八糟的意外,这种情况建议使用 pyenv,从 A 机器整体搬到 B ;
    2.通常在%python 安装路径%\Lib\site-packages
    3. pip freeze > requirements.txt 了解下
    ksupertu
        2
    ksupertu  
       2018-03-21 22:29:18 +08:00
    补充楼上,到新机器安装:
    ```
    pip install -r requirements -i https://pypi.douban.com/simple
    ```
    使用豆瓣源加速,包管理也可以使用最新的 pipenv
    yonoho
        3
    yonoho  
       2018-03-21 22:38:26 +08:00
    进入 python 解释器,随便选一个目标包,import 进来看看就知道了,如:
    >>> import requests
    >>> requests
    <module 'requests' from '/xx/yy/lib/python/site-packages/requests'>
    scukmh
        4
    scukmh  
       2018-03-22 00:36:26 +08:00 via Android
    pip -V 了解一下?
    qwjhb
        5
    qwjhb  
       2018-03-22 09:10:13 +08:00
    如果像我一样要从联网机器搬到断网的机器
    pip download -r requirements.txt
    pip install --no-index --find-link /local/path/
    capljf
        6
    capljf  
       2018-03-22 10:15:37 +08:00
    pip show 包名
    Hopetree
        7
    Hopetree  
       2018-03-22 10:25:50 +08:00
    requirements.txt 才是王道
    mio101
        8
    mio101  
       2018-03-22 11:34:38 +08:00
    docker 了解一下
    cyspy
        9
    cyspy  
       2018-03-22 15:54:52 +08:00
    ArchLinux 的做法是:对于要使用的其他软件,用系统的 pacman 来管理,安装后与 pip 的 global 安装等价。这样,在删除了软件之后就可以顺便删掉 python 包。对于开发,直接用 venv
    saximi
        10
    saximi  
    OP
       2018-03-28 19:49:54 +08:00
    @qwjhb 请问如果两台机器都是断网状态, 其中一台装好了各种包,要如何才能迁移到另外一台机器上呢,机器间可以用 U 盘复制。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1236 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 18:01 · PVG 02:01 · LAX 11:01 · JFK 14:01
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.