Python Module is already installed but ModuleNotFound - python

I am still a beginner in Python.
I use Jupyter Notebook and want to import XlsxWriter, but it doesnt seem to work.
This is what I do in the Notebook which i usually open through the pycharm terminal:
import numpy as np
import pandas as pd
import sys
!{sys.executable} -m pip install --user XlsxWriter
import XlsxWriter
However i get the following error message:
Requirement already satisfied: XlsxWriter in c:\users\rober\appdata\local\programs\python\python310\lib\site-packages (3.0.3)
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Input In [8], in <cell line: 6>()
3 import sys
4 get_ipython().system('{sys.executable} -m pip install --user XlsxWriter')
----> 6 import XlsxWriter
ModuleNotFoundError: No module named 'XlsxWriter'
Does anyone have an idea what is the problem here?
A simple Script using XlsxWriter in PyCharm works perfectly fine.

you need to install xlsxwriter first
pip install xlsxwriter
ref : https://bobbyhadz.com/blog/python-no-module-named-xlsxwriter

Related

ModuleNotFoundError while importing 'emoji' in Jupyter

I get an error when I import the emoji into my Jupyter notebook.
This is the error I'm getting.
ModuleNotFoundError Traceback (most recent call last)
/var/folders/8v/gry0pxmn7tq64rhkjv504zr00000gn/T/ipykernel_12578/2329533640.py in <module>
2 import pandas as pd
3 import numpy as np
----> 4 import emoji
5 from collections import Counter
6 import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'emoji'
I am using MacOs. How do I solve this?
Did you install the library?
For the installation process via pip:
pip install emoji --upgrade
or via git:
git clone https://github.com/carpedm20/emoji.git
cd emoji
python setup.py install
That being done, you can import emoji into your code.
For further information you can read the installation process on the documentation here.

Error importing seaborn module in Jupyter Notebook

I'm trying to use the seaborn module in jupyter notebook,I alredy installed all the dependecies and the seaborn too,but when I try to run,it's said that it does not have a module seaborn installed
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-ed806232820c> in <module>
1 import pandas as pd
2 import matplotlib.pyplot as plt
----> 3 import seaborn as sns
ModuleNotFoundError: No module named 'seaborn'
Try restarting notebook first.
Make sure that seaborn is installed by same python interpreter used in the notebook.
Easiest way to be certain of this is to run
!pip install --user seaborn in the active notebook (! allows you to run shell command from your notebook)
Additional info for detecting the cause of the problem
You can check which interpreter is used by the notebook by running:
import sys
print(sys.executable)
I assume pip you used initially is not used by python you used to run the notebook (multiple python installations of the system or conda).
To specify which python is used for pip install you can run
<python-path> -m pip install seaborn where <python-path> is output of sys.executable.

No module named 'mlxtend'

I am unable to install the mlextend package in Jupyter Python3 notebook
I have tried pip install mlxtend or pip3 install mlxtend, but either it shows syntax error for some reason on Python2 or it tells to try on the command line in python3. I have tried installing it on command line but it shows "ERROR: Could not find a version that satisfies the requirement mlextend (from versions: none)
ERROR: No matching distribution found for mlextend"
from mlxtend.frequent_patterns import apriori
from mlxtend.frequent_patterns import association_rules
ModuleNotFoundError Traceback (most recent call
last)
<ipython-input-3-73c97be96c5f> in <module>()
----> 1 from mlxtend.frequent_patterns import apriori
2 from mlxtend.frequent_patterns import association_rules
ModuleNotFoundError: No module named 'mlxtend'`enter code here`
You need to use the following command:
pip install mlxtend
You are currently trying to install mlextend (which does not exist) instead of mlxtend.
I had the same issue recently. What worked was importing the module first, and then getting the components:
import mlxtend
from mlxtend.frequent_patterns import apriori
from mlxtend.frequent_patterns import association_rules
To add to the above possible solutions. Under Anaconda/Miniconda environments it is also possible to use conda. Among the various options under https://anaconda.org/conda-forge/mlxtend the following worked for me
conda install -c conda-forge mlxtend
'pip install' works on Python2,if you install for Python3, use
pip3 install mlxtend instead
Use !pip install mlxtend. It will definitely work.
#Import the libraries
#To install mlxtend run : pip install mlxtend
import pandas as pd
from mlxtend.preprocessing import TransactionEncoder
from mlxtend.frequent_patterns import association_rules,apriori

"No module named plotly"

My problem is very simple. I have installed it with sudo pip3 install plotly but I can't import it. I've already tried to reinstall it without effects.
ImportError Traceback (most recent call last)
<ipython-input-1-9d1f271208ac> in <module>()
----> 1 import plotly.plotly as py
2 import plotly.graph_objs as go
3 import pandas as pd
4 from pandas import Series,DataFrame
5 import numpy as np
ImportError: No module named 'plotly'
If this error occurs open Terminal and if you using different source like ZSH or something else change it to bash by running
bash
in terminal and then run
conda install -c https://conda.anaconda.org/plotly plotly
and the problem resolves.

Python - Can't import Seaborn

I'm running iPhyton Notebooks and I'm trying to import the Seaborn package. When I try to import it from the Terminal, it loads up fine, but when I import it through iPython Notebooks, it give me the following error.
I have even tried to re-install Seaborn using both Conda and Pip inside iPython notebooks and still it wont work.
Any idea why?
Thanks.
ImportError Traceback (most recent call last)
<ipython-input-1-417274a1ae6c> in <module>()
1 get_ipython().system(u'conda install seaborn')
2 get_ipython().system(u'pip install seaborn')
----> 3 import seaborn as sb
4
ImportError: No module named seaborn
Try this
import sys
print sys.path
sys.path.append('<path to package in your syste>')
import seaborn
In my Ubuntu 14.4LTS the packages get installed in the following folder
/usr/local/lib/python2.7/dist-packages
So I simply add the package path at run time
Donit install Ipython on all your system. Install it only in the environments you want it. Otherwise Ipython will look for modules in the default path instead of the environment's path.
This is probably where your ipython is looking:
/home/user/anaconda2/lib/python2.7/
It should be looking for modules here:
/home/user/anaconda2/envs/name-of-env/lib/python3.4/
To check the path you type:
import sys
sys.path
Try entering the following in your terminal:
conda install seaborn
It will install seaborn and make it available for you to import into your notebook
Open anaconda prompt and Type
pip install seaborn

Categories