Databricks job cannot find python library imported in the cluster - python

I am trying to run a cron job on my notebook and I get an "no module found" error. When I look at the job logs this is the full error:
ModuleNotFoundError Traceback (most recent call last)
<command-2307930105977041> in <module>
1 from __future__ import print_function
2 import sys
----> 3 import pymysql
ModuleNotFoundError: No module named 'pymysql'
This library has been installed to my cluster that I am running the job from and the notebook that uses this library runs and does not show a ModuleNotFoundError. I ran the import pymysql in it's own cell and it does not throw me back an error, only when I run a job on that notebook do I get an error.
What can be the cause for this?

Related

Why does the pattern package fails to be imported in jupyter notebook yet it is already installed

I installed pattern3 in the cmd with: pip install pattern3
and it was successful I also installed in the jupyter notebook and still it was successful.
However, when I try to import it with import patterns I get this error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_2116/1948699844.py in <module>
----> 1 import patterns
ModuleNotFoundError: No module named 'patterns'
I think you have made a typo. The import statement for the pattern3 module would be import pattern3, not import patterns.
If you have installed the pattern3 module correctly, you should be able to import it by using the new statement.

How can I solve the Import error for scraping

Unable to solve the error.
All the code is taken from the website, but it's not working.
This working environment is jupyter notebook because I tried to work at IDLE in desktop, but it was not worked.
I've tried to install scraping in my computer and succussed.
But still the error is not deleted.
Error messages:
ModuleNotFoundError Traceback (most recent call last)
Input In [5], in <cell line: 5>()
2 get_ipython().run_line_magic('autoreload', '2')
4 from datetime import datetime
----> 5 from scraping import Scraping
6 from complete import Complete
7 from train import Tree_updown, Tree_updown_k
ModuleNotFoundError: No module named 'scraiping'
Code that is generating the error:
%load_ext autoreload
%autoreload 2
from datetime import datetime
from scraping import Scraping
from complete import Complete
from train import Tree_updown, Tree_updown_k
The error says, No module named 'scraiping' but in your code you correctly imported scraping. So I suppose you just entered a typo while copying the error.
To fix it you just have to install the package. Type this in your terminal:
pip install scraping

getting python in Jupyter notebook

I've already installed python3 on my computer.
when I started a new Jupyter notebook I selected python 3
but now on the notebook, it is saying it isn't there
when I run this:
print(python_version())
i get this error:
NameError Traceback (most recent call last)
in
----> 1 print(python_version())
NameError: name 'python_version' is not defined
python_version() function is from platform module; So you have to import it first:
import platform
print(platform.python_version())
Another way to check python version is sys module:
import sys
print(sys.version)

Issue implementing pandas_datareader module

On MacOs
Jupyter Notebook
I'm having issues trying to implement a pandas module, I did pip list and it says that it is installed, so I'm not sure why I get
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-6-84d930aeb84e> in <module>
----> 1 from pandas_datareader import data as wb
ModuleNotFoundError: No module named 'pandas_datareader'
is there something else I need? Thanks.
I'm not sure why it's not working, I tried on VScode as well.

How to Import linear_algebra Python Jupyter Notebook

I am having some difficulty trying to get the linear_algebra module working on Jupyter Notebook in Python. I am trying:
import linear_algebra
But I get the following error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-30-7080be6cdc0f> in <module>()
----> 1 import linear_algebra
ImportError: No module named 'linear_algebra'
I don't get what I am doing wrong
Thank you in advanced for help
The 'linear_algebra' is not a library so you can't simply import it as such. It is a file that has the functions (eg. dot) so you have to make sure your main code file and the linear_algebra.py is at the same directory. I hope this helps.

Categories

Resources