For the life of me, I cannot install and use module 'openpyxl' in Python 3.7 / Windows / and Anaconda.
When I try to run and or debug my program I am consistently error-ed out on:
import openpyxl
ModuleNotFoundError: No module named 'openpyxl'
Although within my Terminal or Anaconda Prompt: It says its installed and requirements already met. i.e. the below
Requirement already satisfied: openpyxl in c:\users\MYSELF\appdata\local\continuum\anaconda3\lib\site-packages (2.6.2)
Requirement already satisfied: jdcal in c:\users\MYSELF\appdata\local\continuum\anaconda3\lib\site-packages (from openpyxl) (1.4)
Requirement already satisfied: et-xmlfile in c:\users\MYSELF\appdata\local\continuum\anaconda3\lib\site-packages (from openpyxl) (1.0.1)
(base) C:\MYSELF\language\python\MLTSS-PDF-Split>pip install openpyxl
Requirement already satisfied: openpyxl in c:\users\MYSELF\appdata\local\continuum\anaconda3\lib\site-packages (2.6.2)
Requirement already satisfied: jdcal in c:\users\MYSELF\appdata\local\continuum\anaconda3\lib\site-packages (from openpyxl) (1.4)
Requirement already satisfied: et-xmlfile in c:\users\MYSELF\appdata\local\continuum\anaconda3\lib\site-packages (from openpyxl) (1.0.1)
(base) C:\gitViews\language\python\MLTSS-PDF-Split>pip3 install openpyxl
Requirement already satisfied: openpyxl in c:\users\MYSELF\appdata\local\continuum\anaconda3\lib\site-packages (2.6.2)
Requirement already satisfied: et-xmlfile in c:\users\MYSELF\appdata\local\continuum\anaconda3\lib\site-packages (from openpyxl) (1.0.1)
Requirement already satisfied: jdcal in c:\users\MYSELF\appdata\local\continuum\anaconda3\lib\site-packages (from openpyxl) (1.4)
I have tried uninstalling and reinstalling, I have tried using pip and pip3.
I have tried using trusted host.
I get no error on the import line within Visual Studio Code; i.e.
import openpyxl
Why cannot use this module ?
As discussed in comments it seems like this may be related to a pathing issue that you are experiencing within Visual Studio Code.
My suggestion would be using the documentation from them to ensure you are pointing to your local version of python and not a virtual environment which may not have openpyxl installed.
https://code.visualstudio.com/docs/python/environments
Related
For some reason I cannot get Pandas to work. A few year back I used Atom as IDE, back then everything was working fine. Now I wanted to refresh my Python skills by using PyCharm, however my first script results in:
ModuleNotFoundError: No module named 'pandas'
According to cmd pandas is installed:
Requirement already satisfied: pandas in c:\users\myname\appdata\local\programs\python\python310\lib\site-packages (1.5.1)
Requirement already satisfied: numpy>=1.21.0 in c:\users\myname\appdata\local\programs\python\python310\lib\site-packages (from pandas) (1.23.4)
Requirement already satisfied: python-dateutil>=2.8.1 in c:\users\myname\appdata\local\programs\python\python310\lib\site-packages (from pandas) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in c:\users\myname\appdata\local\programs\python\python310\lib\site-packages (from pandas) (2022.5)
Requirement already satisfied: six>=1.5 in c:\users\myname\appdata\local\programs\python\python310\lib\site-packages (from python-dateutil>=2.8.1->pandas) (1.16.0)
Uninstalling and re-installing does not make a difference. I have tried this a couple of times.
Most likely you're using a different (virtual) environment at the command line and in PyCharm. See JetBrains docs on configuring the Python interpreter for PyCharm.
If Python's configured the way you expect, check the installed packages as well by following these docs
I followed this instruction https://code.visualstudio.com/docs/python/python-tutorial to install pandas. and when I check it is installed:
python -m pip install pandas
Requirement already satisfied: pandas in c:\users\mansour\appdata\local\programs\python\python37\lib\site-packages (1.1.4)
Requirement already satisfied: pytz>=2017.2 in c:\users\mansour\appdata\local\programs\python\python37\lib\site-packages (from pandas) (2020.4)
Requirement already satisfied: numpy>=1.15.4 in c:\users\mansour\appdata\local\programs\python\python37\lib\site-packages (from pandas) (1.19.1)
Requirement already satisfied: python-dateutil>=2.7.3 in c:\users\mansour\appdata\local\programs\python\python37\lib\site-packages (from pandas) (2.8.1)
Requirement already satisfied: six>=1.5 in c:\users\mansour\appdata\roaming\python\python37\site-packages (from python-dateutil>=2.7.3->pandas) (1.15.0)
I am running this command in Visual Studio Code Python terminal.
but in my code, I have this error:
and when I run the application, I am getting this error:
Why I am getting this error?
it may be the reason for the environment. please check the correct environment is select or not while running the code.
I Think you have installed in different environments and running the code in different environments.
Openpyxl works fine in Anaconda but in Visual Studio Code I am receiving the following error:
ModuleNotFoundError: No module named 'openpyxl'.
When I install it, it shows already installed.
C:\Users\XXXXXXX>pip install openpyxl
Requirement already satisfied: openpyxl in c:\programdata\anaconda3\lib\site-packages (3.0.0)
Requirement already satisfied: jdcal in c:\programdata\anaconda3\lib\site-packages (from openpyxl) (1.4.1)
Requirement already satisfied: et-xmlfile in c:\programdata\anaconda3\lib\site-packages (from openpyxl) (1.0.1)
Does anyone have any solutions to get this to work in VS Code?
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)
I have been working on a program for a while now and never had this issue. I installed Kivy for a seperate program and then all of a sudden I get an error saying ModuleNotFoundError: No module named 'pandas' for my first program. I tried reinstalling it through CMD but it's already there.
C:\Users\xxxxx>python -m pip install pandas
Requirement already satisfied: pandas in c:\users\xxxxx\appdata\roaming\python\python37\site-packages (0.25.3)
Requirement already satisfied: python-dateutil>=2.6.1 in c:\users\xxxxx\appdata\roaming\python\python37\site-packages (from pandas) (2.8.0)
Requirement already satisfied: numpy>=1.13.3 in c:\users\xxxxx\appdata\roaming\python\python37\site-packages (from pandas) (1.16.4)
Requirement already satisfied: pytz>=2017.2 in c:\users\xxxxx\appdata\roaming\python\python37\site-packages (from pandas) (2019.1)
Requirement already satisfied: six>=1.5 in c:\users\xxxxx\appdata\roaming\python\python37\site-packages (from python-dateutil>=2.6.1->pandas) (1.12.0)
I also tried uninstalling it and reinstalling it but nothing worked, I have no idea what's going on.
Check if kivy is installed properly and if it runs in virtual environment (ve), if so you should install required packages in your ve directly.
See also kivy's installation guide:
https://kivy.org/doc/stable/installation/installation-windows.html#installing-the-kivy-stable-release