PermissionError:[Errno 13]权限被拒绝:Pipenv安装请求的"Pipfile" [英] PermissionError: [Errno 13] Permission denied: 'Pipfile' for pipenv install requests

查看:519
本文介绍了PermissionError:[Errno 13]权限被拒绝:Pipenv安装请求的"Pipfile"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在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
  • 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 a pipenv: 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆