PermissionError:[Errno 13]权限被拒绝:Pipenv安装请求的"Pipfile" [英] PermissionError: [Errno 13] Permission denied: 'Pipfile' for pipenv install requests
问题描述
我正在尝试在pipenv和virtualenv上遵循此指南: http ://docs.python-guide.org/en/latest/dev/virtualenvs/.问题是,尝试$ pipenv install requests
时遇到问题(我认为应该是$python3 -m pipenv install requests
,因为简单地pipenv
返回未找到的命令.)
I'm trying to follow this guide on pipenv and virtualenv: http://docs.python-guide.org/en/latest/dev/virtualenvs/ . The problem is, I run into a problem when trying to $ pipenv install requests
(which in my case I think should be $python3 -m pipenv install requests
since simply pipenv
returns command not found.)
为什么拒绝权限?
我是终端新手,请多多包涵.
I'm a terminal noob so bear with me.
$ pip3 install --user pipenv
$ python3 -m pipenv
Usage: __main__.py [OPTIONS] COMMAND [ARGS]...
$ python3 -m pipenv install requests
Creating a Pipfile for this project...
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/sahandzarrinkoub/Library/Python/3.6/lib/python/site-packages/pipenv/__main__.py", line 4, in <module>
cli()
File "/Users/sahandzarrinkoub/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/Users/sahandzarrinkoub/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Users/sahandzarrinkoub/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/sahandzarrinkoub/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/sahandzarrinkoub/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/sahandzarrinkoub/Library/Python/3.6/lib/python/site-packages/pipenv/cli.py", line 895, in install
ensure_project(three=three, python=python)
File "/Users/sahandzarrinkoub/Library/Python/3.6/lib/python/site-packages/pipenv/cli.py", line 180, in ensure_project
ensure_pipfile(validate=validate)
File "/Users/sahandzarrinkoub/Library/Python/3.6/lib/python/site-packages/pipenv/cli.py", line 141, in ensure_pipfile
project.create_pipfile()
File "/Users/sahandzarrinkoub/Library/Python/3.6/lib/python/site-packages/pipenv/project.py", line 219, in create_pipfile
self.write_toml(data, 'Pipfile')
File "/Users/sahandzarrinkoub/Library/Python/3.6/lib/python/site-packages/pipenv/project.py", line 226, in write_toml
with open(path, 'w') as f:
PermissionError: [Errno 13] Permission denied: 'Pipfile'
推荐答案
确保已添加文档,您正在关注如何执行此操作.
Make sure you've added the UserBase's bin directory to your path (follow the Note box at the documentation you were following to see how to do this).
您提到的第三个命令应该是:pipenv install requests
.
The third command you mentioned should just be: pipenv install requests
.
长版:
自从您开始使用命令行(以及其他想要更深入参考的人)以来,我将对一些命令行概念进行更深入的介绍.
I'll go a little more in depth for some of the command line concepts since you're getting started with the command line (and for others who would like a little more in depth reference).
您显示三个命令:
-
pip3 install --user pipenv
- 这很完美,它将 pipenv 作为用户软件包安装(不适用于整个系统)
-
python3 -m pipenv
- 这什么也没做.您看到的返回的是"用法消息".也就是说,此命令需要一些main.py程序,选项(由于括号是可选的),命令(强制性)和可能更多的参数.如果您看到使用情况消息,则表示您没有按照作者的意图调用该程序.
-
python3 -m pipenv install requests
- 这应该只是
pipenv install requests
.但是,直到您将UserBase的bin添加到路径中(您会收到pipenv: command not found
错误),它才起作用.
pip3 install --user pipenv
- This is perfect, it installs pipenv as a user package (not avalible to the entire system)
python3 -m pipenv
- This doesn't do anything. What you see returned is a "Usage message". It's saying this command expects some main.py program, options (optional because in parenthesis), a command (mandatory) and potentially more arguments. If you see a usage message it means you did not call that program the way its author intended.
python3 -m pipenv install requests
- This should just be
pipenv install requests
. But it won't work until you've added UserBase's bin to your path (you'll get apipenv: command not found
error).
您的 PATH
是您的shell搜索您列出的命令的地方.请在 Mac或Linux 或<一个href ="http://windowsitpro.com/systems-management/how-can-i-add-new-folder-my-system-path" rel ="nofollow noreferrer"> Windows .
作为文档,您正在关注以下内容: ,您要运行python3 -m site
,将得到类似以下内容的输出:
As the documentation you were following mentions, you want to run python3 -m site
, you'll get output something like the following:
$ python -m site
.
.
.
USER_BASE: '/Users/<myusername>/Library/Python/3.6' (exists)
USER_SITE: '/Users/<myusername>/Library/Python/3.6/lib/python/site-packages' (exists)
ENABLE_USER_SITE: True
现在您知道USER_BASE
的位置了,在末尾添加/bin
并将其添加到PATH中.再次查看特定于操作系统的说明,但是在OSX上,您可以将export PATH="$PATH:/Users/<myusername>/Library/Python/3.6/bin
添加到~/.profile
中,运行source ~/.profile
,并且当您输入命令pipenv
时,shell现在将搜索该目录.
Now that you know where your USER_BASE
is, add a /bin
onto the end and add it to your PATH. Again see OS specific instructions but on OSX you can add export PATH="$PATH:/Users/<myusername>/Library/Python/3.6/bin
to your ~/.profile
, run source ~/.profile
, and your shell will now search that directory when you enter the command pipenv
.
这篇关于PermissionError:[Errno 13]权限被拒绝:Pipenv安装请求的"Pipfile"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!