我正在使用python 3.7.5运行Catalina MacOS。我正在尝试运行ansible脚本来安装VM。这需要python> = 2.6和PyVmomi。我已经通过pip安装了PyVomi和pyVim。两者均已成功安装。运行剧本时,出现以下错误信息。不知道我在想什么。
TASK [Create a virtual machine on given ESXi hostname] *************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named pyVim
fatal: [localhost -> localhost]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (PyVmomi) on MacBook-Pro.local's Python /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python. Please read module documentation and install in the appropriate location"}
答案 0 :(得分:1)
ArunJose_Intel是正确的。该模块是pyvmomi,而不是pyVim。尽管错误表明pyVim库丢失。我在目录中看到了它,这具有误导性。按照他的建议,我将pip install命令改为安装pyvmomi。
pip安装pyvmomi
我能够在导入pyVim的情况下运行python脚本。谢谢阿伦
答案 1 :(得分:0)
您可能已为错误的python可执行文件安装了PyVomi和pyVim。您必须确保通过pip安装到正确的python。您正在将软件包安装到计算机中存在的python3.x中。您要做的是将pip软件包安装到剧本的python
答案 2 :(得分:0)
很抱歉造成混乱。我是通过pip3安装的,是的,它们安装在python3目录中。
pip3 install PyVmomi
Requirement already satisfied: PyVmomi in /usr/local/lib/python3.7/site-packages (6.7.3)
Requirement already satisfied: requests>=2.3.0 in /usr/local/lib/python3.7/site-packages (from PyVmomi) (2.22.0)
Requirement already satisfied: six>=1.7.3 in /usr/local/lib/python3.7/site-packages (from PyVmomi) (1.13.0)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/site-packages (from requests>=2.3.0->PyVmomi) (2019.9.11)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.7/site-packages (from requests>=2.3.0->PyVmomi) (1.25.7)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.7/site-packages (from requests>=2.3.0->PyVmomi) (3.0.4)
Requirement already satisfied: idna<2.9,>=2.5 in /usr/local/lib/python3.7/site-packages (from requests>=2.3.0->PyVmomi) (2.8)
pip3 install pyVim
Requirement already satisfied: pyVim in /usr/local/lib/python3.7/site-packages (3.0.2)
Requirement already satisfied: docopt in /usr/local/lib/python3.7/site-packages (from pyVim) (0.6.2)
Requirement already satisfied: prompt-toolkit<3.1.0,>=2.0.0 in /usr/local/lib/python3.7/site-packages (from pyVim) (3.0.2)
Requirement already satisfied: pyflakes in /usr/local/lib/python3.7/site-packages (from pyVim) (2.1.1)
Requirement already satisfied: pygments in /usr/local/lib/python3.7/site-packages (from pyVim) (2.5.2)
Requirement already satisfied: six in /usr/local/lib/python3.7/site-packages (from pyVim) (1.13.0)
Requirement already satisfied: wcwidth in /usr/local/lib/python3.7/site-packages (from prompt-toolkit<3.1.0,>=2.0.0->pyVim) (0.1.7)
答案 3 :(得分:0)
我修复了。
pip3安装成功
这使得可以使用python3