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

时间:2019-04-28 23:20:10

标签: python python-3.x virtualenv pipenv

我开始了一个新项目,并希望像过去七次一样通过pipenv创建虚拟环境。我是Pipenv的初学者/新手,但是设法让事情做自己想要的事情,并且在我自己无法解决之前没有遇到任何重大问题。我真的很高兴没有在系统上安装大量的依赖项,并希望坚持使用虚拟环境。

要创建问题,我只需要事先在包含或不包含文件的新文件夹中生成一个新的锁定文件。已经生成的锁定文件可以正常工作而没有错误(尚未尝试在较早的项目中安装新的依赖项)。

终端

->工作区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.

我希望把锁文件放到这里,并且我将为我的项目安装所需的依赖项,但是我却陷入了这个错误。我对一般的系统管理知识很少,这就是为什么我尽量避免在系统范围内安装依赖项/软件包。

我已经检出了名为:“ OError:[Errno 26]文本文件忙:'/…myvirtualenv / bin / python'”的线程,但让我无法更进一步解决问题。

希望有人能够帮助我。

1 个答案:

答案 0 :(得分:1)

我使用的是通过python创建的别名通过python(python -run pipenv)使用pipenv,而不是使用bin文件的路径(〜/ usr / local / bin / pipenv)。更改别名以引用路径即可解决问题。