0
我試圖用python3在我的流浪者centos7上創建一個virtualenv,並且發生以下情況。我能用它做什麼嗎? virtualenv的版本是13.1.2,python是3.5.1。謝謝。[Python]未能創建virtualenv
$ virtualenv -p python3 venv
Running virtualenv with interpreter /usr/local/bin/python3
Using base prefix '/usr/local'
Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/virtualenv.py", line 2363, in <module>
main()
File "/usr/local/lib/python3.5/site-packages/virtualenv.py", line 832, in main
symlink=options.symlink)
File "/usr/local/lib/python3.5/site-packages/virtualenv.py", line 994, in create_environment
site_packages=site_packages, clear=clear, symlink=symlink))
File "/usr/local/lib/python3.5/site-packages/virtualenv.py", line 1192, in install_python
copy_required_modules(home_dir, symlink)
File "/usr/local/lib/python3.5/site-packages/virtualenv.py", line 1131, in copy_required_modules
copyfile(filename, dst_filename, symlink)
File "/usr/local/lib/python3.5/site-packages/virtualenv.py", line 468, in copyfile
os.makedirs(os.path.dirname(dest))
File "/usr/local/lib/python3.5/os.py", line 241, in makedirs
mkdir(name, mode)
FileExistsError: [Errno 17] File exists: 'venv/lib/python3.5/lib-dynload'
看起來您已經在該目錄中有一個(可能已損壞的)virtualenv'venv',並且virtualenv默認不會覆蓋現有文件。嘗試刪除它('rm -rf venv')並再次運行創建命令,或者使用['--clear'](https://virtualenv.readthedocs.org/en/latest/reference.html#cmdoption--清除)切換爲virtualenv。 – user1248490
我嘗試刪除並創建venv幾次,即使使用--clear,它仍然無法正常工作。有什麼方法可以修復破壞的virtualenv嗎?我試圖用pip重新安裝它,但不能工作。或者我應該重新安裝整個分區以節省時間。 – wachiu
如果您嘗試在同步文件夾內創建virtualenv,則可能會導致符號鏈接未正確創建,如[this]中的問題(http://stackoverflow.com/questions/5907359/problem-setting-up- a-virtualenv)問題。 – user1248490