我正在尝试遵循有关 pipenv 和 virtualenv 的指南:http ://docs.python-guide.org/en/latest/dev/virtualenvs/ 。问题是,我在尝试时遇到了问题$ pipenv install requests(在我的情况下我认为应该是$python3 -m pipenv install requests因为只是pipenv返回未找到的命令。)
为什么权限被拒绝?
我是一个终端菜鸟,所以请耐心等待。
$ 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'
Run Code Online (Sandbox Code Playgroud)
确保您已将UserBase的 bin 目录添加到您的路径中(遵循文档中的注释框您所关注查看如何执行此操作)。
您提到的第三个命令应该是:pipenv install requests.
更长的版本:
自从您开始使用命令行以来,我将更深入地了解一些命令行概念(以及其他想要更深入参考的人)。
您显示三个命令:
pip3 install --user pipenvpython3 -m pipenvpython3 -m pipenv install requestspipenv install requests. 但是,除非您将 UserBase 的 bin 添加到您的路径中(您会收到pipenv: command not found错误),否则它不会起作用。您PATH的 shell 将在您的位置搜索您列出的命令。请参阅在Mac、Linux或Windows上更改您的路径。
正如您所关注的文档所提到的,您想运行python3 -m site,您将获得如下输出:
$ 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
Run Code Online (Sandbox Code Playgroud)
既然您知道自己的USER_BASE位置,请/bin在末尾添加一个并将其添加到您的 PATH 中。再次查看特定于操作系统的说明,但在 OSX 上,您可以添加export PATH="$PATH:/Users/<myusername>/Library/Python/3.6/bin到您的~/.profile运行中source ~/.profile,当您输入命令时,您的 shell 现在将搜索该目录pipenv。
| 归档时间: |
|
| 查看次数: |
14897 次 |
| 最近记录: |