创建了以下virtualenv
mkvirtualenv -p python3 cola-management-services
运行pip install
pip install pytz
并收到以下错误:
Collecting pytz
Downloading https://devpi.dev.aws.company.com/root/pypi/+f/xxx/716540xxyyccabb/pytz-2017.3-py2.py3-none-any.whl (511kB)
100% |████████████████████████████████| 512kB 7.6MB/s
Installing collected packages: pytz
Exception:
Traceback (most recent call last):
File "/Users/jameslin/virtualenvs/cola-management-services/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Users/jameslin/virtualenvs/cola-management-services/lib/python3.6/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Users/jameslin/virtualenvs/cola-management-services/lib/python3.6/site-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/Users/jameslin/virtualenvs/cola-management-services/lib/python3.6/site-packages/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Users/jameslin/virtualenvs/cola-management-services/lib/python3.6/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/Users/jameslin/virtualenvs/cola-management-services/lib/python3.6/site-packages/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/Users/jameslin/virtualenvs/cola-management-services/lib/python3.6/site-packages/pip/wheel.py", line 287, in clobber
ensure_dir(dest) # common for the 'include' path
File "/Users/jameslin/virtualenvs/cola-management-services/lib/python3.6/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/Users/jameslin/virtualenvs/cola-management-services/bin/../lib/python3.6/os.py", line 210, in makedirs
makedirs(head, mode, exist_ok)
File "/Users/jameslin/virtualenvs/cola-management-services/bin/../lib/python3.6/os.py", line 210, in makedirs
makedirs(head, mode, exist_ok)
File "/Users/jameslin/virtualenvs/cola-management-services/bin/../lib/python3.6/os.py", line 220, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/lib'
第一次看到这个问题......不确定是什么问题。
尝试使用python2和新的virtualenv,同样的问题。我记得在不同的virtualevn上安装pytz并没有遇到这个问题。
答案 0 :(得分:0)
在python3中没有使用virtualenv,但是在python2中,使用pip时它不需要sudo。猜你可能需要使用pip3
答案 1 :(得分:0)
嗯,奇怪的是,该文件夹包含setup.cfg,其中包含以下内容
[install]
prefix=
如果我删除了setup.cfg
文件,则pip install工作正常......
答案 2 :(得分:0)
我能想到的最简单的解决方案是以管理员身份运行CMD提示。