No module named openpyxl - Python 3.6 - OSX - python

I've installed openpyxl from the Terminal using
pip3 install openpyxl
without any problems. I've even double-checked by simply running import openpyxl from the Terminal window once Python is running, and it imports no problem.
The problem starts when I try and import openpyxl from a script I'm building to work with a spreadsheet. I'm using Sublime Text and can't even get past the import openpyxl at the beginning of the script without running into the following error:
Traceback (most recent call last):
File "/Users/wcw/Desktop/test.py", line 1, in
import openpyxl
ImportError: No module named openpyxl
How can this be happening? I know I've installed openpyxl correctly from the Terminal window without any errors so how can my script not find the module?

Try to do:
pip3 install --user openpyxl
Doing the --user worked for me when I tried to run my .py files with matplot lib modules which worked in 3.5 but not in 3.6.

I have the same problem.
I've installed the openpyxl succesfully via Anaconda
!pip3 install --upgrade openpyxl
Collecting openpyxl Using cached
https://files.pythonhosted.org/packages/95/8c/83563c60489954e5b80f9e2596b93a68e1ac4e4a730deb1aae632066d704/openpyxl-3.0.3.tar.gz
Requirement already satisfied, skipping upgrade: jdcal in
/Users/a18301335/Library/Python/3.8/lib/python/site-packages (from
openpyxl) (1.4.1) Requirement already satisfied, skipping upgrade:
et_xmlfile in
/Users/a18301335/Library/Python/3.8/lib/python/site-packages (from
openpyxl) (1.0.1) Installing collected packages: openpyxl Found
existing installation: openpyxl 1.8.6
Uninstalling openpyxl-1.8.6:
Successfully uninstalled openpyxl-1.8.6 Running setup.py install for openpyxl ... done Successfully installed openpyxl-3.0.3
But when I try to use tat library I get an error No module named openpyxl
import openpyxl
ModuleNotFoundError: No module named 'openpyxl'
If I try to import openpyxl in Terminal, I don't have the error. What's wrong?

This may be overly simplistic, but I had the same problem. I installed the module successfully but import openpyxl resulted in an error. I needed to close IDLE and start a new session. After that, my import command worked just fine.

Related

Why cant I use my newly downloaded python library?

So ive tried to install customtkinter and the installation was successfull
Using cached customtkinter-4.6.3-py3-none-any.whl (246 kB)
Requirement already satisfied: darkdetect in c:\users\omen1\appdata\local\programs\python\python311\lib\site-packages (from customtkinter) (0.7.1)
Installing collected packages: customtkinter
Successfully installed customtkinter-4.6.3
But when i then go to vs code and write import customtkinter and run it says
Traceback (most recent call last):
File "c:\Users\OMEN1\OneDrive\Skrivbord\python projects\database.py", line 290, in <module>
import customtkinter
ModuleNotFoundError: No module named 'customtkinter'
I have tried to uninstall and re-install
My pip is also fully uppdated aswell as my python 3.11
Ive tried multiple things
Ensure that the interpreter you're using in VSCode is aligned to where you installed the library.
For example if you installed it with Python3, your VSCode may be pointed to Python2 instead.
Additionally, according to the PyPi link for that library - "To use CustomTkinter, just place the /customtkinter folder from this repository next to your program, and then you can do import customtkinter."

Problem reading excel with last version of Pandas

Well, I recently bought a new computer and installed Spyder as well as Python, and updated the libraries up-to-date using pip. Everything works well except for Pandas when I try to import an excel file.
This is my code
import pandas as pd
filename = "sample_sheet.xlsx"
data = pd.read_excel(filename)
And this is the error I get
ImportError: Missing optional dependency 'xlrd'. Install xlrd >= 1.0.0 for Excel support Use pip or conda to install xlrd.
I have already installed xlrd as well as openpyxl with pip, and when trying to install it again it shows the following message
Requirement already satisfied: xlrd in c:\users\lucas\appdata\local\programs\python\python39\lib\site-packages (2.0.1)
I am not the only one with this error, a friend of mine has it too. Has anyone came up with a solution? Thank you in advance for your answers.
Just copy xlrd and openpypl files (or your complete site-packages folder, if you want) from Python folder into your user appdata, to the path where python is installed.
In your case, copy all content from C:\users\lucas\appdata\local\programs\python\python39\lib\site-packages to C:\Program Files\Python39\Lib\site-packages or C:\Python39, depending on where you have installed Python

Cannot Import Textblob In Jupyter After successfully installing it

I have downloaded and installed textblob using pip and now while i am importing it on jupyter notebook i get an error as:
No module named 'textblob'
Have checked Link1 and Link2 amongst other similar thread on SO but following the recommended steps i am not still able to download it.
Running CMD as an administrator i am getting this error while trying to load the package again:
Requirement already satisfied, skipping upgrade
This is how i am calling it in jupyter -
from textblob import TextBlob
pip version - pip 19.0.3

No module named 'xlrd' when xlrd module is installed

I am using Jupyter Notebook in an environment, and when I try to use xlrd module I get "No module named 'xlrd". I checked others Stack Overflow posts and I installed the module xlrd using the command pip3 install xlrd. but still it continues to throw me the error No module named 'xlrd.
I tried again to install may be something went wrong and I get Requirement already satisfied: xlrd in /usr/local/lib/python3.6/site-packages which I believe it's ok. Is it possible that I have to update my environment in order to use the new installs? If so how do I do it?

Python packages not available after install with pip

I am working on a Macbook with Python 2.7.5 pre-installed. I installed the pandas package via command-line with the following code.
pip install pandas
This completed without errors. However, when I try to run the following code in Netbeans, I get an error.
if __name__ == "__main__":
import pandas as pd
The error is: ImportError: No module named pandas
When I try to re-install the pandas package in the terminal I get the message: Requirement already satisfied (use --upgrade to upgrade): pandas in /usr/local/lib/python2.7/site-packages
What am I doing wrong here?
Thanks for the help!

Categories