2017-10-15 2 views
1

플랫폼을 작동하지 : 우분투 17.04 서버 설치가 파이썬 2.7 및 파이썬 3.5을 포함lsb_release 소스에서 파이썬 3.6.3을 설치 한 후

우분투 17.04 서버. 소스에서 수동으로 Python 3.6.3을 설치했습니다. 그러나, lsb_release -a 실패 :

[email protected]:~# lsb_release -a 
Traceback (most recent call last): 
    File "/usr/bin/lsb_release", line 25, in <module> 
    import lsb_release 
ModuleNotFoundError: No module named 'lsb_release' 

하지만 #!/usr/bin/python3.5 -Es
#!/usr/bin/python3 -Es 에서 파일 lsb_release의 첫 번째 줄을 수정하면 그것은 다시 작동합니다.

python3.5

[email protected]:~# python3.5 
Python 3.5.3 (default, Sep 14 2017, 22:58:41) 
[GCC 6.3.0 20170406] on linux 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import sys 

>>> sys.path 
['', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages'] 

>>> import lsb_release 

>>> exit() 

python3

[email protected]:~# python3 
Python 3.6.3 (default, Oct 14 2017, 20:35:42) 
[GCC 6.3.0 20170406] on linux 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import sys 

>>> sys.path 
['', '/usr/local/lib/python36.zip', '/usr/local/lib/python3.6', '/usr/local/lib/python3.6/lib-dynload', '/root/.local/lib/python3.6/site-packages', '/usr/local/lib/python3.6/site-packages'] 

>>> import lsb_release 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ModuleNotFoundError: No module named 'lsb_release' 

>>> exit() 

사람이 그것을 해결하는 방법을 알고 않습니다 여기

[email protected]:~# lsb_release -a 
LSB Version: core-9.20160110ubuntu5-amd64:core-9.20160110ubuntu5-noarch:security-9.20160110ubuntu5-amd64:security-9.20160110ubuntu5-noarch 
Distributor ID: Ubuntu 
Description: Ubuntu 17.04 
Release: 17.04 
Codename: zesty 

는 모듈 검색 경로입니까? 감사.

+0

왜 PPA에서 Python 3.6을 설치하지 않았습니까? –

+0

'make altinstall '대신에'make install'을 사용하신 것 같습니다. (https://docs.python.org/3.6/using/unix.html#building-python 참조). 파이썬 3 심볼릭 링크를 가리켜 복구 할 수있다.5 바이너리이지만 전체 OS를 다시 설치해야 할 수도 있습니다. – snakecharmerb

답변

0

솔루션 :

sudo ln -s /usr/share/pyshared/lsb_release.py /usr/local/lib/python3.6/site-packages/lsb_release.py 

설명 :

우리는 /usr/bin/lsb_release

#!/usr/bin/python3 -Es 

# lsb_release command for Debian 
# (C) 2005-10 Chris Lawrence <[email protected]> 
# This package is free software; you can redistribute it and/or modify 
# it under the terms of the GNU General Public License as published by 
# the Free Software Foundation; version 2 dated June, 1991. 
# This package is distributed in the hope that it will be useful, 
# but WITHOUT ANY WARRANTY; without even the implied warranty of 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
# GNU General Public License for more details. 
# You should have received a copy of the GNU General Public License 
# along with this package; if not, write to the Free Software 
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 
# 02110-1301 USA 
from optparse import OptionParser 
import sys 
import os 
import re 

import lsb_release 

중요한 단계는 import lsb_release이지만, 문제는 Python 3.6이없는 것입니다 볼 수 이 모듈.

따라서 python3.5에서 python3.6까지 python3을 우선해야합니다. 그래서 lsb_release이 고장났습니다.

를 확인하기 위해, 우리는 python3.6에서 볼 수 있습니다 python3.5에서 다음

➜ ~ python3.6 
Python 3.6.4 (default, Feb 6 2018, 16:57:12) 
[GCC 5.4.0 20160609] on linux 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import lsb_release 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ModuleNotFoundError: No module named 'lsb_release' 

:

➜ ~ python3.5 
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import lsb_release 
>>> lsb_release.__file__ 
'/usr/lib/python3/dist-packages/lsb_release.py' 

는 곳 파일 : 그래서

➜ ~ ll /usr/lib/python3/dist-packages/lsb_release.py 
lrwxrwxrwx 1 root root 38 Jul 7 2016 /usr/lib/python3/dist-packages/lsb_release.py -> ../../../share/pyshared/lsb_release.py 

,이 모듈을 lsb_release 존재하는 사람 : python3.5python3.6에는 존재하지 않습니다. 그리고 우리는 결국 그것을 발견합니다!

이제 원래 lsb_release.py 파일에 대한 링크를 추가하여 문제를 해결해 보겠습니다!

나를 위해 작동합니다!

관련 문제