简体   繁体   English

使用python2.7在Windows 8上安装python2.4 virtualenv-错误base64.py

[英]Installing python2.4 virtualenv on windows 8 with python2.7 - error base64.py

I have a problem with a Python2.4 virtualenv install on my python2.7 windows. 我在python2.7窗口上安装Python2.4 virtualenv时遇到问题。

I created a virtualenv for my python2.7 programms and want to build virtualenv for my python2.4 program 我为我的python2.7程序创建了virtualenv并想为我的python2.4程序构建virtualenv

SO i first DL and install python2.4 on my windows8 with no problem... folder c:/Python24 ( python 2.7 is on c:/Python27 ) 所以我首先DL并在Windows8上毫无问题地安装python2.4 ...文件夹c:/ Python24(python 2.7在c:/ Python27上)

On en shell 在外壳上

 D:\xxx\projet_django>virtualenv --python=c:/Python24/python.exe env_python2
.4
Running virtualenv with interpreter c:/Python24/python.exe
'import site' failed; use -v for traceback
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\virtualenv.py", line 10, in ?
    import base64
  File "C:\Python27\Lib\base64.py", line 346
    with open(args[0], 'rb') as f:
            ^
SyntaxError: invalid syntax

So i try 所以我尝试

C:\>cd Python24

C:\Python24>python
'import site' failed; use -v for traceback
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import base64
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "C:\Python27\Lib\base64.py", line 346
    with open(args[0], 'rb') as f:
            ^

SO the problem is base64.py use the WITH fonction doesn't exist on python2.4 ... so why my python2.7 virtualenv try to use python2.4 to install my virtualenv ? 所以问题是base64.py在python2.4上不使用WITH函式...那么为什么我的python2.7 virtualenv尝试使用python2.4安装我的virtualenv?

And what can i do now ? 我现在该怎么办? thx laurent 劳伦斯

The problem is that Python 2.4 is badly installed: when you start it, it shouldn't try to read the files from C:\\Python27\\Lib\\ . 问题在于Python 2.4安装不正确:启动它时,它不应尝试从C:\\Python27\\Lib\\读取文件。 I can't tell more where the problem is, but you should be able to figure it out, if necessary by reinstalling Python 2.4 from scratch from the official installer. 我无法详细说明问题出在哪里,但是如果有必要,您可以通过从官方安装程序重新安装Python 2.4来解决问题。

EDIT: also, look out for the PYTHONPATH environment variable. 编辑:另外,请注意PYTHONPATH环境变量。 Maybe it is pointing to C:\\Python27 . 也许它指向C:\\Python27 That's a bad idea :-) 那是个坏主意:-)

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

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