当前位置:   article > 正文

mac:python安装路径_mac python安装目录

mac python安装目录

了解python的安装路径,有利于处对python安装的管理。比如删除多余的python,可以在这些路径中查询处理。

一、Mac下python的安装路径

1、Mac自带python路径

/System/Library/Frameworks/Python.framework/Versions
  • 1

对应系统 pip 安装的第三方库的安装路径:

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
  • 1

2、Mac中自己安装的python3.x的路径

/Library/Frameworks/Python.framework/Versions/3.x
  • 1

对应 pip 安装的第三方库的安装路径: ( 比如Django Flask 都是安装在这里 )

Library/Frameworks/Python.framework/Versions/3.x/lib/python3.x/site-packages
  • 1

3、homebrew安装python路径

/usr/local/Cellar/python@2         //@2 表示python版本,也可以是 @3
  • 1

homebrew 安装的外部包的安装路径:

/Library/Python
  • 1

二、brew 安装指定版本 python3

1、安装

brew install python@3.8
  • 1

2、错误处理

xcrun: error: invalid active developer path (/Applications/Xcode.app/Contents/Developer)
原因:卸载了Xcode或者升级Xcode导致
处理

sudo xcode-select -r
sudo /usr/bin/xcode-select --switch /Library/Developer/CommandLineTools
xcode-select -p
  • 1
  • 2
  • 3

相关:Mac 之 Command Line Tools

3、查看安装路径

方法一:terminal

python3
>>> import sys
>>> sys.path
  • 1
  • 2
  • 3

打印结果:

['', 
'/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python38.zip', 
'/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8', 
'/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/lib-dynload', 
'/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages', 
'/Library/Python/3.8/site-packages', 
'/Library/Python/3.8/site-packages/Django-4.0.4-py3.8.egg']
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

方法二:terminal

which python3
  • 1

方法三:mac版Pycharm第三方库路径

/Library/Python
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/308266?site
推荐阅读
相关标签
  

闽ICP备14008679号