2014-02-19 2 views
18

python 2.7.3ipython 1.2이 있고 Linux 시스템 (ubuntu 12.04)에 올바르게 실행 중이지만 교과 과정에 필요한 matplotlab의 업데이트 된 버전을 설치하려고했습니다.Python/IPython ImportError : site라는 모듈이 없습니다.

이제 터미널

user$ sudo easy_install -U distribute 
user$ export PYTHONHOME=/usr/lib/python2.7/ 

에 내가 시도하고 실행할 때마다이 코드 줄을 실행 한 후 python 또는 ipython 나는

ImportError: no module named site 

가 어떻게/역 않는 오류 메시지가이 문제를 해결 얻을? ? 나는 너무 길다. 다른 비슷한 문제를 살펴 보았지만 아무도 Linux을 사용하지 않았으며 무엇을해야할지 모르겠습니다.

답변

15

PYTHONHOME

Change the location of the standard Python libraries. By default, the libraries are searched in prefix/lib/pythonversion and exec_prefix/lib/pythonversion, where prefix and exec_prefix are installation-dependent directories, both defaulting to /usr/local.

When PYTHONHOME is set to a single directory, its value replaces both prefix and exec_prefix. To specify different values for these, set PYTHONHOME to prefix:exec_prefix.

시도하여 PYTHONHOME 정리 :

sudo apt-get install python-matplotlib 

(자세한 here)

,536 :

user$ export PYTHONHOME= 

하기 matplotlib를 설치, 나는 다음과 같은 추천

+0

예! 그 일을, 정말 고마워! apt-get install을 사용하여 액세스 한 matplotlib 버전은 최신 버전이 아닙니다 ... sudo pip install --upgrade matplotlib를 사용해 보았지만 "python setup.py egg_info 명령이 오류 코드 1로 실패했습니다"라는 메시지가 나타납니다. 나는 그것을 그냥두고 내일을 시도하고 해결할지도 모른다. – user2635779

+2

안녕하세요. 그게 효과가 있다면 답변을 수락하십시오, 이것은 또한 답이없는 질문 목록에서 귀하의 질문을 제거합니다. 건배 –

+3

export PYTHONHOME =/usr/ 나를 위해 해줬습니다 – bennos

8

unset PYTHONHOME 시스템 기본값을 사용하거나 export PYTHONHOME=/usr을 사용하여 파이썬이 '/lib/python2.7'(또는 어떤 버전이든)을 추가하여 접두사를 지정할 수 있습니다.

export PYTHONHOME=/usr/lib/python2.7 인 경우 Python은 존재하지 않는 폴더 /usr/lib/python2.7/lib/python2.7에서 라이브러리를 찾습니다.

하고 export PYTHONHOME= 경우, 현재 작업 디렉토리에 lib를 찾기 위해 파이썬을 말하고있다 : 당신의 파이썬 경로 설정을 해제 할 수

[email protected]:~$ PYTHONHOME= strace -estat64 /usr/bin/python 
stat64("lib/python2.7/", 0xff870ee0) = -1 ENOENT (No such file or directory) 
stat64("lib/python2.7", 0xff870ee0)  = -1 ENOENT (No such file or directory) 
stat64("lib", {st_mode=S_IFDIR|0755, st_size=8192, ...}) = 0 
stat64("lib/python2.7/", 0xff873efc) = -1 ENOENT (No such file or directory) 
stat64("lib/python2.7/plat-i386-linux-gnu", 0xff870ee0) = -1 ENOENT (No such file or directory) 
stat64("lib/python2.7", 0xff870ee0)  = -1 ENOENT (No such file or directory) 
stat64("lib", {st_mode=S_IFDIR|0755, st_size=8192, ...}) = 0 
stat64("lib/python2.7/plat-i386-linux-gnu", 0xff873efc) = -1 ENOENT (No such file or directory) 
stat64("lib/python2.7/lib-tk", 0xff870ee0) = -1 ENOENT (No such file or directory) 
stat64("lib/python2.7", 0xff870ee0)  = -1 ENOENT (No such file or directory) 
stat64("lib", {st_mode=S_IFDIR|0755, st_size=8192, ...}) = 0 
stat64("lib/python2.7/lib-tk", 0xff873efc) = -1 ENOENT (No such file or directory) 
stat64("lib/python2.7/lib-old", 0xff870ee0) = -1 ENOENT (No such file or directory) 
stat64("lib/python2.7", 0xff870ee0)  = -1 ENOENT (No such file or directory) 
stat64("lib", {st_mode=S_IFDIR|0755, st_size=8192, ...}) = 0 
stat64("lib/python2.7/lib-old", 0xff873efc) = -1 ENOENT (No such file or directory) 
stat64("lib/python2.7/lib-dynload", 0xff870ee0) = -1 ENOENT (No such file or directory) 
stat64("lib/python2.7", 0xff870ee0)  = -1 ENOENT (No such file or directory) 
stat64("lib", {st_mode=S_IFDIR|0755, st_size=8192, ...}) = 0 
stat64("lib/python2.7/lib-dynload", 0xff873efc) = -1 ENOENT (No such file or directory) 
ImportError: No module named site 
13

TRY ... 리눅스/맥에서

, 당신은 할 수 다음 명령을 사용하십시오.

unset PYTHONPATH 
unset PYTHONHOME 
+1

cygwin에서 파이썬을 설치 한 후,이 문제가있었습니다. 이전 버전의 파이썬은 윈도우즈 프로그램에 의해 설치되었고 cygwin이 PYHONHOME 변수에 넣었던 것입니다. 위의 설명대로 설정을 취소하면 Cygwin에서 파이썬이 잘 작동합니다. – johnm

+0

완벽한 대답! –

관련 문제