简体   繁体   English

OError: [Errno 26] 文本文件忙:'/...myvirtualenv/bin/python'

[英]OError: [Errno 26] Text file busy: '/…myvirtualenv/bin/python'

I try to recreate the virtualenv:我尝试重新创建 virtualenv:

foo_bar_d@aptguettler:~$ virtualenv --system-site-packages . 

I get this exception:我得到这个例外:

foo_bar_d@aptguettler:~$ virtualenv --system-site-packages .
New python executable in /home/foo_bar_d/bin/python
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 711, in main
    symlink=options.symlink)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 924, in create_environment
    site_packages=site_packages, clear=clear, symlink=symlink))
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 1230, in install_python
    shutil.copyfile(executable, py_executable)
  File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 26] Text file busy: '/home/foo_bar_d/bin/python'

Does someone know why this exception happens?有人知道为什么会发生这种异常吗?

I had the exact same problem :)我遇到了完全相同的问题:)

virtualenv works (afaik) by modifying a copy of the python executable in the virtualenv directory area. virtualenv 通过修改 virtualenv 目录区域中的 python 可执行文件的副本来工作(afaik)。

You must have a process using the virtualenv already so the copy of the python executable is 'in use' (technically it's mmap()'ed into memory whilst it's executing).您必须已经有一个使用 virtualenv 的进程,因此 python 可执行文件的副本“正在使用”(从技术上讲,它在执行时将 mmap() 放入内存中)。

Unless you need to change the setup of a virtualenv you don't need to re-run the virtualenv command every time - once it's setup you just activate it when needed.除非您需要更改 virtualenv 的设置,否则您不需要每次都重新运行 virtualenv 命令 - 一旦设置好,您只需在需要时激活它。

As to why it happens - It's possible that you have a service running at boot time:至于为什么会发生 - 您可能在启动时运行了一项服务:

ps -ef | grep python

Kill Python Processes running on your system with pkill python使用pkill python杀死系统上运行的 Python 进程

I will work我会工作

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

相关问题 OSError: [Errno 26] 文本文件繁忙 - OSError: [Errno 26] Text file busy 使用 .sh 文件 python 安装库和依赖项([Errno 26] 文本文件繁忙) - install libraries and dependencies with .sh file python ([Errno 26] Text file busy) AWS Lambda “errorMessage”:“[Errno 26] 文本文件忙” - AWS Lambda "errorMessage": "[Errno 26] Text file busy" OSError: [Errno 26] 文本文件忙于使用 synced_folder 的 vagrant - OSError: [Errno 26] Text file busy on vagrant with synced_folder 多线程python上的“文本文件繁忙”错误 - “Text file busy” error on multithreading python FileExistsError:[Errno 17] 文件存在:'/usr/bin/python' -&gt; '/home/had2000/.virtualenvs/cv/bin/python' - FileExistsError: [Errno 17] File exists: '/usr/bin/python' -> '/home/had2000/.virtualenvs/cv/bin/python' Chromedriver 文本文件忙 - Chromedriver text file busy 如何在Python中将.bin文件复制到文本文件 - How to copy a .bin file to a text file in Python 在Python中检查文件是否已打开(由于错误:“文本文件正忙”) - Check if files are open (because of error: “text file busy”) in Python python:无法打开文件&#39;C:\\usr\\local\\bin\\django-admin.py&#39;:[Errno 2]没有这样的文件或目录 - python: can't open file 'C:\\usr\\local\\bin\\django-admin.py': [Errno 2] No such file or directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM