I am running Catalina MacOS with python 3.7.5. I am trying to run an ansible script to install a VM. This Requires python >= 2.6 and PyVmomi. I have installed PyVomi and pyVim via pip. Both were installed successfully. When I run the playbook, I get the error message below. Not sure what I am missing.
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"}
ArunJose_Intel is correct. The module is pyvmomi, not pyVim. Although the error indicates that the pyVim library was missing. It was misleading as I could see it in my directory. Following his advice I changed the pip install command to install pyvmomi instead.
pip install pyvmomi
I was able to run the python script with pyVim imported. Thank you Arun.
You might have installed PyVomi and pyVim for the wrong python executable. You have to make sure you are installing via pip to the right python. You are installing the packages to the python3.x present in your machine. What you have to do is to install the pip packages to the python of the playbook
I fixed it.
pip3 install ansible
That made ansible use python3
Sorry for the confusion. I have installed this via pip3, is yes they are installed in the python3 directories.
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)
Related
I need help understanding whats wrong here.
I will try to explain this as best I can, but Im a bit new to PythonAnywhere. I get this error:
Traceback (most recent call last):
File "/home/HelliottChip/mysite/app/__init__.py", line 6, in <module>
from flask_migrate import Migrate
ModuleNotFoundError: No module named 'flask_migrate'
When trying to run my main.py file. But i have them all installed as shown in this code:
17:14 ~/.local/bin $ pip install Flask-SQLAlchemy email_validator flask-mail pyjwt flask-bootstrap flask-moment
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2
.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Looking in links: /usr/share/pip-wheels
Requirement already satisfied: Flask-SQLAlchemy in /usr/local/lib/python2.7/dist-packages (2.4.1)
Requirement already satisfied: email_validator in /home/HelliottChip/.local/lib/python2.7/site-packages (1.1.2)
Requirement already satisfied: flask-mail in /usr/local/lib/python2.7/dist-packages (0.9.1)
Requirement already satisfied: pyjwt in /usr/local/lib/python2.7/dist-packages (1.7.1)
Requirement already satisfied: flask-bootstrap in /usr/local/lib/python2.7/dist-packages (3.3.7.1)
Requirement already satisfied: flask-moment in /home/HelliottChip/.local/lib/python2.7/site-packages (0.11.0)
Requirement already satisfied: Flask>=0.10 in /usr/local/lib/python2.7/dist-packages (from Flask-SQLAlchemy) (1.1.1)
Requirement already satisfied: SQLAlchemy>=0.8.0 in /usr/local/lib/python2.7/dist-packages (from Flask-SQLAlchemy) (1.3.10)
Requirement already satisfied: idna>=2.0.0 in /usr/local/lib/python2.7/dist-packages (from email_validator) (2.8)
Requirement already satisfied: dnspython>=1.15.0 in /home/HelliottChip/.local/lib/python2.7/site-packages (from email_validator) (1.16.0)
Requirement already satisfied: blinker in /usr/local/lib/python2.7/dist-packages (from flask-mail) (1.4)
Requirement already satisfied: dominate in /usr/local/lib/python2.7/dist-packages (from flask-bootstrap) (2.4.0)
Requirement already satisfied: visitor in /usr/local/lib/python2.7/dist-packages (from flask-bootstrap) (0.1.3)
Requirement already satisfied: itsdangerous>=0.24 in /usr/local/lib/python2.7/dist-packages (from Flask>=0.10->Flask-SQLAlchemy) (1.1.0)
Requirement already satisfied: Jinja2>=2.10.1 in /usr/local/lib/python2.7/dist-packages (from Flask>=0.10->Flask-SQLAlchemy) (2.10.3)
Requirement already satisfied: click>=5.1 in /usr/local/lib/python2.7/dist-packages (from Flask>=0.10->Flask-SQLAlchemy) (7.0)
Requirement already satisfied: Werkzeug>=0.15 in /usr/local/lib/python2.7/dist-packages (from Flask>=0.10->Flask-SQLAlchemy) (0.16.0)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/lib/python2.7/dist-packages (from Jinja2>=2.10.1->Flask>=0.10->Flask-SQLAlchemy) (0.23)
I have gone down about every website I can find on how to fix this, but I'm lost. This is for a Flask app I have worked on for a while on Replit.com and it worked fine until the transfer to PythonAnywhere. I have been trying to get this out for around two weeks now ^~^ but yet still no luck to my avail. I used a lot of this guide to help me with it, as I am also practicing my web deployment skills. (Don't need judgment on the fact I'm using flask -3-) But could anyone take thier time to help me with this? If you can, thanks a lot.
Check if your web app on PythonAnywhere is set up to be run by Python 2.7 -- I see you're using pip install outside of a virtual environment which by default will use pip for Python 2.7 as you can see in the output (btw. it won't work on PythonAnywhere, you need to provide --user option). If you want to install packages outside of virtual environment for different version of Python, use pipX.X install --user ... (where X.X should be replaced by required Python version). Also, remember to reload the web app every time the setup is changed. And if you're really stuck, maybe try contacting PythonAnywhere support (support#pythonanywhere.com) or use their forums?
Hello #TutorialWarrior9776 my suggestion is:
Step 1:
Install virtualenv,
pip install virtualenv
Step 2:
Create env
virtualenv -p python3.8 NAME_ENV
Step 3:
Activate env and Install requirements.txt (file generated local machine contains module flask_migrate)
source NAME_ENV/bin/active
pip install -r requirements.txt
Step 4:
Set your env path in the section (web) of pythonanywhere, that's all;
https://help.pythonanywhere.com/pages/Virtualenvs/
(Section: Step 3: Configure your app to use this virtualenv)
Hope this helps ;)
I am trying to pip install a CLI and it successfully installs.
pip3 install databricks-cli
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: databricks-cli in ./Library/Python/3.8/lib/python/site-packages (0.14.3)
Requirement already satisfied: click>=6.7 in ./Library/Python/3.8/lib/python/site-packages (from databricks-cli) (7.1.2)
Requirement already satisfied: requests>=2.17.3 in ./Library/Python/3.8/lib/python/site-packages (from databricks-cli) (2.25.1)
Requirement already satisfied: six>=1.10.0 in /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages (from databricks-cli) (1.15.0)
Requirement already satisfied: tabulate>=0.7.7 in ./Library/Python/3.8/lib/python/site-packages (from databricks-cli) (0.8.9)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./Library/Python/3.8/lib/python/site-packages (from requests>=2.17.3->databricks-cli) (1.26.4)
Requirement already satisfied: idna<3,>=2.5 in ./Library/Python/3.8/lib/python/site-packages (from requests>=2.17.3->databricks-cli) (2.10)
Requirement already satisfied: chardet<5,>=3.0.2 in ./Library/Python/3.8/lib/python/site-packages (from requests>=2.17.3->databricks-cli) (4.0.0)
Requirement already satisfied: certifi>=2017.4.17 in ./Library/Python/3.8/lib/python/site-packages (from requests>=2.17.3->databricks-cli) (2020.12.5)
But when I go ahead and try to use a command I am given an error that it cannot find the command.
~ databricks --version
zsh: command not found: databricks
I needed the following command.
sudo -H pip3 install databricks-cli
C:\Users\sbhandari>python --version
Python 3.9.1
C:\Users\sbhandari>pip install pytest
Collecting pytest
Using cached pytest-6.2.1-py3-none-any.whl (279 kB)
Requirement already satisfied: toml in c:\users\sbhandari\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pytest) (0.10.2)
Requirement already satisfied: pluggy<1.0.0a1,>=0.12 in c:\users\sbhandari\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pytest) (0.13.1)
Requirement already satisfied: iniconfig in c:\users\sbhandari\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pytest) (1.1.1)
Requirement already satisfied: py>=1.8.2 in c:\users\sbhandari\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pytest) (1.10.0)
Requirement already satisfied: packaging in c:\users\sbhandari\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pytest) (20.8)
Requirement already satisfied: attrs>=19.2.0 in c:\users\sbhandari\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pytest) (20.3.0)
Requirement already satisfied: atomicwrites>=1.0; sys_platform == "win32" in c:\users\sbhandari\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pytest) (1.4.0)
Requirement already satisfied: colorama; sys_platform == "win32" in c:\users\sbhandari\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from pytest) (0.4.4)
Requirement already satisfied: pyparsing>=2.0.2 in c:\users\sbhandari\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from packaging->pytest) (2.4.7)
Installing collected packages: pytest
WARNING: The scripts py.test.exe and pytest.exe are installed in 'C:\Users\sbhandari\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pytest-6.2.1
WARNING: You are using pip version 20.2.3; however, version 20.3.3 is available.
You should consider upgrading via the 'C:\Users\sbhandari\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe -m pip install --upgrade pip' command.
C:\Users\sbhandari>pytest
'pytest' is not recognized as an internal or external command,
operable program or batch file.
it worked on my computer,i think its not working on your computer because you haven't added it to system variables(PATH),here's how you can do so
pytest and other scripts are mostly present in a directory(in python folder) named 'Scripts'.maybe yours is somewhere else and if so then type pytest.exe in start menu and copy the file location and add it to system variables.if this doesnt work try re-installing pytest or python.
Edit:if you check the output pip is telling you that WARNING: The scripts py.test.exe and pytest.exe are installed in 'C:\Users\sbhandari\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.just add the directory above on your path and it should solve your problem
I just installed awscli using pip pip install awscli==1.15 --user. This was the output -
Requirement already satisfied: awscli==1.15 in /Users/xyz/Library/Python/2.7/lib/python/site-packages (1.15.0)
Requirement already satisfied: colorama<=0.3.7,>=0.2.5 in /Users/xyz/Library/Python/2.7/lib/python/site-packages (from awscli==1.15) (0.3.7)
Requirement already satisfied: docutils>=0.10 in /Users/xyz/Library/Python/2.7/lib/python/site-packages (from awscli==1.15) (0.15.2)
Requirement already satisfied: rsa<=3.5.0,>=3.1.2 in /Users/xyz/Library/Python/2.7/lib/python/site-packages (from awscli==1.15) (3.4.2)
Requirement already satisfied: PyYAML<=3.12,>=3.10 in /Users/xyz/Library/Python/2.7/lib/python/site-packages (from awscli==1.15) (3.12)
Requirement already satisfied: botocore==1.10.0 in /Users/xyz/Library/Python/2.7/lib/python/site-packages (from awscli==1.15) (1.10.0)
Requirement already satisfied: s3transfer<0.2.0,>=0.1.12 in /Users/xyz/Library/Python/2.7/lib/python/site-packages (from awscli==1.15) (0.1.13)
Requirement already satisfied: pyasn1>=0.1.3 in /Users/xyz/Library/Python/2.7/lib/python/site-packages (from rsa<=3.5.0,>=3.1.2->awscli==1.15) (0.4.7)
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /Users/xyz/Library/Python/2.7/lib/python/site-packages (from botocore==1.10.0->awscli==1.15) (0.9.4)
Requirement already satisfied: python-dateutil<2.7.0,>=2.1 in /Users/xyz/Library/Python/2.7/lib/python/site-packages (from botocore==1.10.0->awscli==1.15) (2.6.1)
Requirement already satisfied: futures<4.0.0,>=2.2.0; python_version == "2.6" or python_version == "2.7" in /Users/xyz/Library/Python/2.7/lib/python/site-packages (from s3transfer<0.2.0,>=0.1.12->awscli==1.15) (3.3.0)
Requirement already satisfied: six>=1.5 in /Users/xyz/Library/Python/2.7/lib/python/site-packages (from python-dateutil<2.7.0,>=2.1->botocore==1.10.0->awscli==1.15) (1.12.0)
And it is also showing in the list of pip packages.
Package Version
-------------------------------------- --------
altgraph 0.10.2
ansible 2.8.0
asn1crypto 0.24.0
awscli 1.15.0
But when I'm trying to run any aws command I get command not found for example -
wwww:~ rgsd$ aws
-bash: aws: command not found
wwww:~ rgsd$ awscli
-bash: awscli: command not found
wwww:~ rgsd $ aws s3
-bash: aws: command not found
I also executed the command to include this in my $PATH.
export PATH=~/.local/bin:$PATH
But no success on that. I use Mac machine.
What am I doing wrong ?
For Modern macos/OSX, you need to find your ~/Library/Python/$version/bin directory and add it to your $PATH. This will help you locate the one where aws got installed.
$ ls -d ~/Library/Python/*/bin/aws
/Users/bbronosky/Library/Python/3.6/bin/aws
So based on that I added this line to my .bashrc
export PATH=$HOME/Library/Python/3.6/bin:$PATH
This link is helpful -
https://www.edureka.co/community/6039/post-installation-aws-cli-not-added
I am trying a deployment script, which will need to import boto3, when I run the script, it give me error message:
ImportError: No module named boto3
then I ran:
pip install boto3
it returns:
Requirement already satisfied: boto3 in /usr/local/lib/python3.7/site-packages (1.9.228)
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages (from boto3) (0.9.4)
Requirement already satisfied: s3transfer<0.3.0,>=0.2.0 in /Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages (from boto3) (0.2.1)
Requirement already satisfied: botocore<1.13.0,>=1.12.228 in /usr/local/lib/python3.7/site-packages (from boto3) (1.12.228)
Requirement already satisfied: docutils<0.16,>=0.10 in /Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages (from botocore<1.13.0,>=1.12.228->boto3) (0.14)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1; python_version >= "2.7" in /usr/local/lib/python3.7/site-packages (from botocore<1.13.0,>=1.12.228->boto3) (2.8.0)
Requirement already satisfied: urllib3<1.26,>=1.20; python_version >= "3.4" in /Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages (from botocore<1.13.0,>=1.12.228->boto3) (1.25.3)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/site-packages (from python-dateutil<3.0.0,>=2.1; python_version >= "2.7"->botocore<1.13.0,>=1.12.228->boto3) (1.12.0)
I ran pip3 install boto3, still it gave the same output as above.
then I ran the deployment script, the same errors with complaining
ImportError: No module named boto3
Any ideas where goes wrong?
I'm using mac 10.14.6 version.
Requirement already satisfied: boto3 in /usr/local/lib/python3.7/site-packages (1.9.228)
Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages (from boto3) (0.9.4)
Make sure that /usr/local/lib/python3.7/site-packages and /Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages are in the path.
Use the below code to temporarily append it to the path.:
import sys
print(sys.path)
sys.path.append('/usr/local/lib/python3.7/site-packages')
sys.path.append('/Users/xiaoyiliu/Library/Python/3.7/lib/python/site-packages')
print(sys.path)
import boto3
Make sure you have installed your package with the pip associated with a particular python, use:
python -m pip install <pkg>
instead of:
pip install <pkg>