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

无人久伴 提交于 2019-12-12 09:33:32

问题


I try to recreate the 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?


回答1:


I had the exact same problem :)

virtualenv works (afaik) by modifying a copy of the python executable in the virtualenv directory area.

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).

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.

As to why it happens - It's possible that you have a service running at boot time:

ps -ef | grep python


来源:https://stackoverflow.com/questions/40403502/oerror-errno-26-text-file-busy-myvirtualenv-bin-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!