简体   繁体   English

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

[英]Virtualenv with different python version doesn't work on windows

i have Python 2.6 as my default python on Windows 7, and i'm trying to get a virtual env with Python 2.7 我将Python 2.6作为Windows 7上的默认python,并且我尝试使用Python 2.7获得虚拟环境

I have python 2.6 in C:\\Python26, and python 2.7 in C:\\Python27 我在C:\\ Python26中有python 2.6,在C:\\ Python27中有python 2.7

When i try to use virtualenv -p i get this 当我尝试使用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']

Am i doing something wrong? 难道我做错了什么?

I run virtualenv with the python I want and don't use the -p option: 我使用想要的python运行virtualenv,并且不使用-p选项:

(edited to fix path) (已修改以修复路径)

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

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM