[英]How to backup/restor python virtualenv?
A python virtualenv is full of symlinks: python virtualenv充满了符号链接:
$ virtualenv venv
Running virtualenv with interpreter /usr/bin/python2
New python executable in venv/bin/python2
Also creating executable in venv/bin/python
Installing setuptools, pip...done.
$ tree venv/lib/
venv/lib/
├── python2.7
│ ├── _abcoll.py -> /usr/lib/python2.7/_abcoll.py
│ ├── _abcoll.pyc
│ ├── abc.py -> /usr/lib/python2.7/abc.py
│ ├── abc.pyc
│ ├── codecs.py -> /usr/lib/python2.7/codecs.py
│ ├── codecs.pyc
│ ├── copy_reg.py -> /usr/lib/python2.7/copy_reg.py
│ ├── copy_reg.pyc
│ ├── distutils
│ │ ├── distutils.cfg
│ │ ├── __init__.py
│ │ └── __init__.pyc
│ ├── encodings -> /usr/lib/python2.7/encodings
│ ├── fnmatch.py -> /usr/lib/python2.7/fnmatch.py
│ ├── fnmatch.pyc
│ ├── genericpath.py -> /usr/lib/python2.7/genericpath.py
│ ├── genericpath.pyc
What is the recommended way to backup/restor them ? 推荐的备份/还原方式是什么?
My first attempt using rdiff-backup has derefence all symbolic links when I restor backup back. 当我还原备份时,我第一次尝试使用rdiff-backup取消了所有符号链接的引用。
rdiff-backup normally copies symlinks as they are and does not reference them. rdiff-backup通常按原样复制符号链接,而不引用它们。 Did you maybe add the --include-symlinks option ?
您是否添加了--include-symlinks选项?
"cp -p" or "rsync -a" would also preserve symlinks. “ cp -p”或“ rsync -a”也将保留符号链接。
Its easy to just freeze the environment into a text file and install from it later! 只需将环境冻结到文本文件中,然后再从中进行安装就很容易了!
pip freeze > requirements.txt
then when you want to install 然后当你想安装
pip install -r requirements.txt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.