简体   繁体   English

创建环境时如何读取和修复 pipenv 错误?

[英]How to read and fix pipenv errors when creating an environment?

I started a new project and wanted to create a virtual environment via pipenv as I have been doing for the last seven times.我开始了一个新项目,并想通过 pipenv 创建一个虚拟环境,就像我过去七次所做的那样。 I am a beginner/novice to pipenv, but manage to get the things to do what I want and have not experienced any major problem before I could not solve on my own.我是pipenv的初学者/新手,但设法让事情做我想做的事情,并且在我自己无法解决之前没有遇到任何重大问题。 I really enjoy not having tons of dependencies installed on my system, and would like to stick with a virtual environment.我真的很喜欢没有在我的系统上安装大量依赖项,并且希望坚持使用虚拟环境。

To create the problem I simply have to generate a new lock file in a fresh folder with or without files beforehand.要创建这个问题,我只需要事先在带有或不带有文件的新文件夹中生成一个新的锁定文件。 Already generated lockfiles work without errors (have not tried installing new dependencies in older project).已经生成的锁文件可以正常工作(没有尝试在旧项目中安装新的依赖项)。

terminal终端

-> workspace pipenv lock -> 工作区 pipenv 锁

Creating a virtualenv for this project…
Pipfile: /home/djursing/workspace/Pipfile
Using /usr/bin/python3 (3.6.7) to create virtualenv…
⠋ Creating virtual environment...Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/djursing/.local/share/virtualenvs/workspace-kiFyzAmW/bin/python3

✘ Failed creating virtual environment 
[pipenv.exceptions.VirtualenvCreationException]:   File "/home/djursing/.local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
[pipenv.exceptions.VirtualenvCreationException]:       return f(get_current_context(), *args, **kwargs)
[pipenv.exceptions.VirtualenvCreationException]:   File "/home/djursing/.local/lib/python3.6/site-packages/pipenv/cli/command.py", line 319, in lock
[pipenv.exceptions.VirtualenvCreationException]:       ensure_project(three=state.three, python=state.python, pypi_mirror=state.pypi_mirror)
[pipenv.exceptions.VirtualenvCreationException]:   File "/home/djursing/.local/lib/python3.6/site-packages/pipenv/core.py", line 574, in ensure_project
[pipenv.exceptions.VirtualenvCreationException]:       pypi_mirror=pypi_mirror,
[pipenv.exceptions.VirtualenvCreationException]:   File "/home/djursing/.local/lib/python3.6/site-packages/pipenv/core.py", line 506, in ensure_virtualenv
[pipenv.exceptions.VirtualenvCreationException]:       python=python, site_packages=site_packages, pypi_mirror=pypi_mirror
[pipenv.exceptions.VirtualenvCreationException]:   File "/home/djursing/.local/lib/python3.6/site-packages/pipenv/core.py", line 935, in do_create_virtualenv
[pipenv.exceptions.VirtualenvCreationException]:       extra=[crayons.blue("{0}".format(c.err)),]
[pipenv.exceptions.VirtualenvCreationException]: Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/djursing/.local/lib/python3.6/site-packages/virtualenv.py", line 2502, in <module>
    main()
  File "/home/djursing/.local/lib/python3.6/site-packages/virtualenv.py", line 793, in main
    symlink=options.symlink,
  File "/home/djursing/.local/lib/python3.6/site-packages/virtualenv.py", line 1070, in create_environment
    install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages=site_packages, clear=clear, symlink=symlink)
  File "/home/djursing/.local/lib/python3.6/site-packages/virtualenv.py", line 1392, in install_python
    shutil.copyfile(executable, py_executable)
  File "/usr/lib/python3.6/shutil.py", line 121, in copyfile
    with open(dst, 'wb') as fdst:
OSError: [Errno 26] Text file busy: '/home/djursing/.local/share/virtualenvs/workspace-kiFyzAmW/bin/python3'

Failed to create virtual environment.

I expected the lockfile to and I would be on my way to install the desired dependencies for my project, but I am instead stuck at this error.我希望锁定文件可以,并且我将在途中为我的项目安装所需的依赖项,但我却陷入了这个错误。 I have very little knowledge of general system management, which is why I try to stay away from installing dependencies/packages system wide.我对一般系统管理知之甚少,这就是为什么我尽量避免在系统范围内安装依赖项/包。

I have checked out the thread named: "OError: [Errno 26] Text file busy: '/…myvirtualenv/bin/python'", but got me no closer to solve the problem.我已经查看了名为:“OError: [Errno 26] Text file busy: '/...myvirtualenv/bin/python'”的线程,但没有让我更接近解决问题。

Hope someone is able to help me.希望有人能够帮助我。

I was using pipenv via python (python -run pipenv) with an alias I have made, instead of using the path to the bin file (~/usr/local/bin/pipenv).我通过 python (python -run pipenv) 使用 pipenv 和我创建的别名,而不是使用 bin 文件的路径 (~/usr/local/bin/pipenv)。 Changing the alias to refer to the path solved the problem.更改别名以引用路径解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM