我已经开始使用我的Mac来安装Python包,就像我在工作中使用Windows PC一样;但是,在我的Mac上,当写入日志文件或site-packages时,我经常遇到permission denied错误。
因此,我考虑在
日志文件I/O错误的示例回溯:
因此,我考虑在
sudo
下运行pip install <package>
,但考虑到我只想将其安装在当前用户帐户下,这样做是否安全/可接受?日志文件I/O错误的示例回溯:
Command /usr/bin/python -c "import setuptools;__file__='/Users/markwalker/build/pycrypto/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /var/folders/tq/hy1fz_4j27v6rstzzw4vymnr0000gp/T/pip-k6f2FU-record/install-record.txt failed with error code 1 in /Users/markwalker/build/pycrypto
Storing complete log in /Users/markwalker/Library/Logs/pip.log
Traceback (most recent call last):
File "/usr/local/bin/pip", line 8, in <module>
load_entry_point('pip==1.1', 'console_scripts', 'pip')()
File "/Library/Python/2.7/site-packages/pip-1.1-py2.7.egg/pip/__init__.py", line 116, in main
return command.main(args[1:], options)
File "/Library/Python/2.7/site-packages/pip-1.1-py2.7.egg/pip/basecommand.py", line 141, in main
log_fp = open_logfile(log_fn, 'w')
File "/Library/Python/2.7/site-packages/pip-1.1-py2.7.egg/pip/basecommand.py", line 168, in open_logfile
log_fp = open(filename, mode)
IOError: [Errno 13] Permission denied: '/Users/markwalker/Library/Logs/pip.log'
更新
这可能是由于权限问题,然而最好的方法是为您的Python项目使用虚拟环境。除非绝对必要,否则应避免运行sudo pip
。
cd /tmp; sudo pip install foo
' 是一个足够的解决方法。 - Brian Cain