2017-10-15 3 views
1

プラットフォームからのPython 3.6.3をインストールし動作していません。 ソースから手動でPython 3.6.3をインストールしました。しかし、lsb_release -aに失敗しました:lsb_releaseは、後のソース

[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の最初の行を変更した場合、それが再び動作します。ここで

[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 

は、モジュール検索パスです:誰もがそれを修正する方法を

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() 

を知っていますか?ありがとう。

+0

PPAからPython 3.6をインストールしなかったのはなぜですか? –

+0

'make altinstall'ではなく' make install'を使ったようですね。 (https://docs.python.org/3.6/using/unix.html#building-pythonを参照)。あなたはあなたの3で 'python3'のシンボリックリンクを指すことによって回復するかもしれません。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ファイルへのリンクを追加して修正しましょう!

それは私のために働く!

関連する問題