简体   繁体   中英

Why is pip installing packages in the current directory instead of the standard site-packages location?

I am using python3.8 and pip3 to attempt to install packages

This is my sample output when I run pip3 list -v

Package    Version Location                                                              Installer
---------- ------- --------------------------------------------------------------------- ---------
GDAL       3.1.2   /usr/local/lib/python3.8/site-packages
numpy      1.19.1  /usr/local/lib/python3.8/site-packages
pip        20.1.1  /usr/local/lib/python3.8/site-packages
protobuf   3.13.0  /usr/local/Cellar/protobuf/3.13.0/libexec/lib/python3.8/site-packages
PyQt5      5.15.0  /usr/local/lib/python3.8/site-packages                                pip
PyQt5-sip  4.19.24 /usr/local/lib/python3.8/site-packages                                pip
setuptools 49.2.0  /usr/local/lib/python3.8/site-packages
six        1.15.0  /usr/local/Cellar/protobuf/3.13.0/libexec/lib/python3.8/site-packages
TBB        0.1     /usr/local/lib/python3.8/site-packages
wheel      0.34.2  /usr/local/lib/python3.8/site-packages

When I run pip3 install requests , a folder called file: is created in the directory from which I ran the pip3 install requests command. Deep down in this newly created directory are the files installed for the requests package: /ExampleDirectory/file:/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages

Why has pip3 installed the package here in the new file: folder instead of the standard location of /usr/local/lib/python3.8/site-packages ?

How can I get pip3 to install the file for the requests package here: /usr/local/lib/python3.8/site-packages ?

Managed to solve this by changing the pip config as suggested by Steve.
Running the command
pip3 config list
gives
global.target='file:///Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages'

Then running the command pip3 config --editor nano edit lets you change global.target to your desired location

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM