GNU/Linux >> Linux の 問題 >  >> Linux

ImportErrorを解決する方法:ConfigParserという名前のモジュールはありませんか?

質問: エラーが発生しましたImportError:ConfigParserという名前のモジュールがありません packstackを実行すると CentOSのコマンド。以下は完全なエラーメッセージです:

$packstack --gen-answer-file=answers.txt
Traceback (most recent call last):
 File "/usr/local/bin/packstack", line 4, in <module>
 __import__('pkg_resources').run_script('packstack==7.0.0', 'packstack')
 import ConfigParser
ImportError: No module named 'ConfigParser'

この問題を解決する方法を教えてください。

解決策:

エラーが示すように、 packstack コマンドは、ConfigParserという名前のPythonモジュールの1つをロードできません。 つまり、ConfigParserモジュールをインストールする必要があります。モジュールを非常に簡単にインストールできるPythonPIPをインストールすることをお勧めします。 PIPをインストールしたら、以下はConfigParserモジュールをインストールするためのコマンドです。

$pip install configparser
Collecting configparser
Using cached configparser-3.3.0r2.tar.gz
Building wheels for collected packages: configparser
Running setup.py bdist_wheel for configparser
Stored in directory: /root/.cache/pip/wheels/1a/3e/f9/d34006ad6b1edfe5006aa704f5ee305c553344a7a6d8550c29
Successfully built configparser
Installing collected packages: configparser
Successfully installed configparser-3.3.0.post2

注: pipinstallconfigparserが失敗した場合 以下に示すようなエラーが発生します:

$pip install ConfigParser
Collecting ConfigParser
Downloading configparser-3.3.0r2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/usr/local/lib/python3.5/site-packages/setuptools/__init__.py", line 5, in <module>
import distutils.core
File "/usr/local/lib/python3.5/distutils/core.py", line 18, in <module>
from distutils.config import PyPIRCCommand
File "/usr/local/lib/python3.5/distutils/config.py", line 7, in <module>
from configparser import ConfigParser
File "/tmp/pip-build-vks_efrb/ConfigParser/configparser.py", line 397
_KEYCRE = re.compile(ur"%\(([^)]+)\)s")
^
SyntaxError: invalid syntax----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-vks_efrb/ConfigParser

次に、ここをクリックして問題を修正します。

その他のエラーと修正という名前のモジュールはありません

  • シェルという名前のモジュールがないのを修正
  • MySQLdbという名前のモジュールがないのを修正
  • virtualenvという名前のモジュールがないのを修正
  • Crypto.Hashという名前のモジュールがないのを修正)
  • system-config-firewall-tuiの実行中にdbusという名前のモジュールがないのを修正[解決済み]

Linux
  1. ImportError:system-config-firewall-tuiの実行中にdbusという名前のモジュールがありません[解決済み]

  2. Oracleasm 用の SELinux モジュールをロードする方法

  3. ioctl() を使用してカーネル モジュールを操作するにはどうすればよいですか?

  1. Anaconda のインストール後、conda コマンドが ImportError:no module named conda.cli で失敗する

  2. ImportError:'appdirs' という名前のモジュールがありません

  3. Letsencrypt が ImportError で失敗しました:インターフェイスという名前のモジュールがありません

  1. ImportErrorを修正する方法:CentOSにvirtualenvという名前のモジュールがありませんか?

  2. [OpenStack]:keystoneclient.shellからimport main ImportError:shellという名前のモジュールがありません

  3. Python 3.6 で UnicodeDecodeError を解決するには?