$ pip install --upgrade setuptools Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: setuptools in /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages (49.2.1) Collecting setuptools Using cached setuptools-62.1.0-py3-none-any.whl (1.1 MB) Installing collected packages: setuptools Successfully installed setuptools-62.1.0
Without arguments print some useful information With arguments print the value of USER_BASE and/or USER_SITE separated by ':'.
Exit codes with --user-base or --user-site: 0 - user site directory is enabled 1 - user site directory is disabled by user 2 - uses site directory is disabled by super user or for security reasons >2 - unknown error # 2. 进入路径,备份文件、编辑文件 cd /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8 cp site.py site_bak.py sudo vim site.py # 3. 修改配置,如下,然后保存退出 # Enable per user site-packages directory # set it to False to disable the feature or True to force the feature ENABLE_USER_SITE = True
# for distutils.commands.install # These values are initialized by the getuserbase() and getusersitepackages() # functions, through the main() function when Python starts. USER_SITE = "/Users/gavin/Library/Python/3.8/lib/python/site-packages" USER_BASE = "/Users/gavin/Library/Python/3.8"