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
GabrielleBellamy
V2EX  ›  Python

请问/Library/ Python /3.9/lib/ Python 这个路径里的 Python 是系统自带的还是自己装的呀?

  •  
  •   GabrielleBellamy ·
    Ryan-the-hito · 2023-01-16 01:33:49 +08:00 · 2614 次点击
    这是一个创建于 460 天前的主题,其中的信息可能已经有所发展或是发生改变。

    最近重装系统后遇到了一个问题,发现 python 有时会把包装到一个路径:

    Macintosh HD/Users/<user name>/Library/Python/3.9/lib/python

    在网上查了一圈,没有得到结果,所以想来问问。根据网上的答案:

    苹果自带 python 的路径是/System/Library/Frameworks/Python.framework/Versions(我发现我的电脑上没有这个路径)和/usr/bin/python(这个路径只有/usr/bin/python3

    自己安装的路径是/Library/Frameworks/Python.framework/Versions/3.x(也是我常用的)

    那么这个Macintosh HD/Users/<user name>/Library/Python/3.9/lib/python是……怎么回事?为什么同样使用 pip 有时候会把包装去这个路径呢?谢谢!

    补充信息:正在使用 2020 ( M1 )的 mbp ,系统是 12.6.2.

    10 条回复    2023-01-16 12:21:05 +08:00
    liprais
        1
    liprais  
       2023-01-16 01:35:21 +08:00 via iPhone
    老司机都知道用 python -m pip
    GabrielleBellamy
        2
    GabrielleBellamy  
    OP
       2023-01-16 01:37:08 +08:00
    @liprais 我一直都是用这个的,所以从来没有担心过路径。但是这不突然发现了这个问题嘛,所以很疑惑~~~
    GabrielleBellamy
        3
    GabrielleBellamy  
    OP
       2023-01-16 01:51:17 +08:00
    增加一个说明~因为发布了图床链接,只好用文字了……

    例如:python3 -m pip install pygetwindow ,它会把包装到 /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages

    类似地,python3 -m pip install pywinctl ,却把包装去了~/Library/Python/3.9/lib/python/site-packages
    GabrielleBellamy
        4
    GabrielleBellamy  
    OP
       2023-01-16 02:12:12 +08:00
    啊我好像明白了,是不是 mac 版 Pycharm 的第三方库路径?不是很了解为啥要分出这一个路径……
    ysc3839
        5
    ysc3839  
       2023-01-16 04:57:00 +08:00 via Android   ❤️ 1
    一个是系统级的一个是用户级的
    zhlxsh
        6
    zhlxsh  
       2023-01-16 05:02:38 +08:00 via iPhone   ❤️ 1
    看你的描述,貌似你的 python3 不是同一个,做好看一下环境变量。echo $PATH 或者看 python3 的路径,which pythin3

    另外我也是 m1 用 brew 装的 python3.9 是在 /opt 下面
    BingoXuan
        7
    BingoXuan  
       2023-01-16 09:49:40 +08:00
    你是不是装了 xcode ,那个目录是 xcode 带的 python 的
    ila
        8
    ila  
       2023-01-16 10:37:24 +08:00
    @BingoXuan 好像 nodejs 也会弄个 python2
    hertzry
        9
    hertzry  
       2023-01-16 10:43:42 +08:00
    我也觉得你用的不是一个 Python ,用 conda 就方便多了。
    GabrielleBellamy
        10
    GabrielleBellamy  
    OP
       2023-01-16 12:21:05 +08:00
    @hertzry 是的,我也装了 conda ,电脑上至少有三套 python 。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   923 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 19:56 · PVG 03:56 · LAX 12:56 · JFK 15:56
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.