2011-06-24 2 views
0

J'utilise une machine partagée. J'essaye d'installer Python 2.6 pour un projet qui utilise Pysco (non supporté sur 2.7), et il y a une installation existante de 2.7 sur la machine que je ne peux pas enlever sans casser les projets d'autres personnes.Erreur de site d'importation Python avec plusieurs versions

J'utilise les binaires 32 bits de Python sous Windows 7.

Lorsque je tente de démarrer Python 2.6, je reçois cette erreur:

'import-site' failed; use -v for traceback 

Il ressemble à Python 2.6 tente de importer des modules à partir de Python 2.7, ce qui provoque l'échec (voir la sortie ci-dessous). Est-ce que quelqu'un sait ce qui pourrait causer cela, et comment cela pourrait être réparé? Merci!

Courir avec l'option -v donne la sortie suivante

# installing zipimport hook 
import zipimport # builtin 
# installed zipimport hook 
# C:\Python27\Lib\site.pyc matches C:\Python27\Lib\site.py 
import site # precompiled from C:\Python27\Lib\site.pyc 
# C:\Python27\Lib\os.pyc matches C:\Python27\Lib\os.py 
import os # precompiled from C:\Python27\Lib\os.pyc 
import errno # builtin 
import nt # builtin 
# C:\Python27\Lib\ntpath.pyc matches C:\Python27\Lib\ntpath.py 
import ntpath # precompiled from C:\Python27\Lib\ntpath.pyc 
# C:\Python27\Lib\stat.pyc matches C:\Python27\Lib\stat.py 
import stat # precompiled from C:\Python27\Lib\stat.pyc 
# C:\Python27\Lib\genericpath.pyc matches C:\Python27\Lib\genericpath.py 
import genericpath # precompiled from C:\Python27\Lib\genericpath.pyc 
# C:\Python27\Lib\warnings.pyc matches C:\Python27\Lib\warnings.py 
import warnings # precompiled from C:\Python27\Lib\warnings.pyc 
# C:\Python27\Lib\linecache.pyc matches C:\Python27\Lib\linecache.py 
import linecache # precompiled from C:\Python27\Lib\linecache.pyc 
# C:\Python27\Lib\types.pyc matches C:\Python27\Lib\types.py 
import types # precompiled from C:\Python27\Lib\types.pyc 
# C:\Python27\Lib\UserDict.pyc matches C:\Python27\Lib\UserDict.py 
import UserDict # precompiled from C:\Python27\Lib\UserDict.pyc 
# C:\Python27\Lib\_abcoll.pyc matches C:\Python27\Lib\_abcoll.py 
import _abcoll # precompiled from C:\Python27\Lib\_abcoll.pyc 
# C:\Python27\Lib\abc.pyc matches C:\Python27\Lib\abc.py 
import abC# precompiled from C:\Python27\Lib\abc.pyc 
# C:\Python27\Lib\_weakrefset.pyc matches C:\Python27\Lib\_weakrefset.py 
import _weakrefset # precompiled from C:\Python27\Lib\_weakrefset.pyc 
import _weakref # builtin 
'import site' failed; traceback: 
Traceback (most recent call last): 
    File "C:\Python27\Lib\site.py", line 62, in <module> 
    import os 
    File "C:\Python27\Lib\os.py", line 398, in <module> 
    import UserDict 
    File "C:\Python27\Lib\UserDict.py", line 84, in <module> 
    _abcoll.MutableMapping.register(IterableUserDict) 
    File "C:\Python27\Lib\abc.py", line 109, in register 
    if issubclass(subclass, cls): 
    File "C:\Python27\Lib\abc.py", line 151, in __subclasscheck__ 
    if subclass in cls._abc_cache: 
    File "C:\Python27\Lib\_weakrefset.py", line 69, in __contains__ 
    return ref(item) in self.data 
TypeError: cannot create weak reference to 'classobj' object 

Répondre

2

Essayez d'utiliser virtualenv. Il est utilisé pour séparer plusieurs instances de python et de ses bibliothèques - vous pouvez avoir autant d'environnements virtuels que possible: python 2.5, 2.6, 2.7, peu importe - avec n'importe quelle combinaison de bibliothèques - donc vous pouvez avoir par exemple cinq instances de python 2.6 différentes ensembles de bibliothèques configurés.

Début de http://pypi.python.org/pypi/virtualenv

+0

Essayer d'installer virtualenv sur Python 2.6 donne l'erreur suivante: ImportError: Aucun module nommé pkg_resources. Cela est probablement dû au fait que l'interpréteur ne démarre pas correctement. – jmite

+0

Aurais-je également besoin d'utiliser virtualenv dans Python 2.7? Je ne veux pas trop y toucher car je ne veux pas casser les projets des autres. – jmite

+0

Pas besoin d'utiliser virtualenv. C'est facultatif - virtualenv ajoute env virtuel sur l'installation python existante - il fait des liens symboliques (ou des raccourcis dans les fenêtres) vers les binaires et les bibliothèques de droite ..... Et en exécutant les scripts d'activation vous les faites par défaut. Pour pkg_resources - avez-vous déjà installé setuptools? –

Questions connexes