具有不同python版本的Virtualenv在Windows上不起作用

时间:2013-04-27 23:04:08

标签: python windows virtualenv

我在Windows 7上使用Python 2.6作为我的默认python,我正在尝试使用Python 2.7获得虚拟环境

我在C:\ Python26中使用python 2.6,在C:\ Python27中使用python 2.7

当我尝试使用virtualenv -p时,我得到了这个

C:\web\xxx>virtualenv -p "C:\Python27\python.exe" --no-site-packages venv
Running virtualenv with interpreter C:\Python27\python.exe
Traceback (most recent call last):
  File "C:\Python26\lib\site-packages\virtualenv.py", line 2577, in <module>
    main()
  File "C:\Python26\lib\site-packages\virtualenv.py", line 979, in main
    no_pip=options.no_pip)
  File "C:\Python26\lib\site-packages\virtualenv.py", line 1081, in create_environment
    site_packages=site_packages, clear=clear))
  File "C:\Python26\lib\site-packages\virtualenv.py", line 1277, in install_python
    copy_required_modules(home_dir)
  File "C:\Python26\lib\site-packages\virtualenv.py", line 1215, in copy_required_modules
    dst_filename = change_prefix(filename, dst_prefix)
  File "C:\Python26\lib\site-packages\virtualenv.py", line 1185, in change_prefix
    (filename, prefixes)
AssertionError: Filename C:\Python26\Lib\os.py does not start with any of these prefixes: ['C:\\Python27']

我做错了吗?

1 个答案:

答案 0 :(得分:1)

我使用我想要的python运行virtualenv,不要使用-p选项:

(编辑修复路径)

C:\web\xxx>C:\Python27\python c:\path\to\virtualenv.py --no-site-packages venv