简体   繁体   中英

Python2: installing networkx

I'm tryng to install networkx on python 2.7.18:

pip2 install networkx

I get the following error:

Running setup.py install for networkx ... error
    ERROR: Command errored out with exit status 1:
     command: /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/1b/8lq89lxj07bd6rvtl1k6g1b80000gn/T/pip-install-xAglEZ/networkx/setup.py'"'"'; _file='"'"'/private/var/folders/1b/8lq89lxj07bd6rvtl1k6g1b80000gn/T/pip-install-xAglEZ/networkx/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file_, '"'"'exec'"'"'))' install --record /private/var/folders/1b/8lq89lxj07bd6rvtl1k6g1b80000gn/T/pip-record-cJQmE6/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/networkx
         cwd: /private/var/folders/1b/8lq89lxj07bd6rvtl1k6g1b80000gn/T/pip-install-xAglEZ/networkx/

and in the end:

error: could not create '/Library/Frameworks/Python.framework/Versions/2.7/share/doc/networkx-2.2': Permission denied
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/1b/8lq89lxj07bd6rvtl1k6g1b80000gn/T/pip-install-xAglEZ/networkx/setup.py'"'"'; _file='"'"'/private/var/folders/1b/8lq89lxj07bd6rvtl1k6g1b80000gn/T/pip-install-xAglEZ/networkx/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file_, '"'"'exec'"'"'))' install --record /private/var/folders/1b/8lq89lxj07bd6rvtl1k6g1b80000gn/T/pip-record-cJQmE6/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/networkx Check the logs for full command output.

What should I do?

This means that you don't have sufficient privileges.


You can either run the command with sudo (if you are a root user):

sudo pip2 install networkx

or just install it just for the current user

pip2 install networkx --user

PS: Consider upgrading to pip3 .


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