ModuleNotFoundError: No module named 'crawler' - python

I am doing a fake news detection as a college project and have written a crawler program for crawling a webpage for information. But when I try to import the crawler into another program it is giving an error of module not found. I am not able to understand how to resolve this issue. I have copied the error here
ModuleNotFoundError Traceback (most recent call last)
in
2 import os
3 from sklearn.utils import shuffle
----> 4 import crawler
5 LEN=2
ModuleNotFoundError: No module named 'crawler'

Related

ImportError: cannot import name 'weather_api_key' from 'config'

I am trying to import an API key from a python file and I get this error:
ImportError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_27940\425884591.py in
9
10 # Import the OpenWeatherMap's API key
---> 11 from config import weather_api_key
ImportError: cannot import name 'weather_api_key' from 'config' (C:\Users\mjrm_\anaconda3\envs\PythonData\lib\site-packages\config_init_.py)
I have done many fixes that I found but I keep getting this error.
I tried changing the py file name and also attempted verifiy loading different packages into my environment, I feel like the error fix is simple but I cannot figure this out

google colab. It gives this error when I execute the training code

It gives this error when I execute the training code.
ModuleNotFoundError
Traceback (most recent call last)
<ipython-input-12-08472a50f5e6> in <module>()
6 import logging
7 logging.getLogger('tensorflow').disabled = True
----> 8 import input_data
9 import resnet_utils
10 import resnet_v2
ModuleNotFoundError: No module named 'input_data'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.

How to import modules from py files

So I received three python files with some functions. It's an util library provided by a third party. When I want to import these in my python file I use this code (as was specified by the third party):
import util.submission as S
import util.vis as V
import util.metrics as M
But then I get this error. I am working in Google Colaboraty and I uploaded the three python files in my current working directory on google colab so I don't understand. How do I fix this? The three files are just named submission.py ; vis.py and metrics.py. Any help here? This should be quite basic but it doesn't seem to work.
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-8-1e1451b5bba0> in <module>()
1
----> 2 import util.submission as S
3 import util.vis as V
4 import util.metrics as M
ModuleNotFoundError: No module named 'util'
Create a folder in your current working directory named utils, and place the three .py files inside of it. You can then use the import statements as you have specified.
https://realpython.com/absolute-vs-relative-python-imports/#syntax-and-practical-examples

ModuleNotFoundError error while importing file in python

I am getting "ModuleNotFoundError" when importing a python file.PFB the code:
testImport.ipynb
feet_in_miles=5280
meters_in_kilometer=1000
beatles=["John Lenon","PAul McCartney",""]
Modules.ipynb:
import testImport
print(testImport.beatles)
On running Modules.ipynb, I am getting the below error:
ModuleNotFoundError Traceback (most recent call last)
in ()
----> 1 import testImport
2 print(testImport.beatles)
ModuleNotFoundError: No module named 'testImport'
Kindly let me know what's the issue.
check in your directory that testImport.py is in the folder where you are running the code . New program should be in same directory

ModuleNotFoundError in Using 3rd party module in external .py file

I installed third party module and its egg file was created in following path
D:\Utkarsh\Lib\site-packages
I am not getting error while importing module in IDLE in following way
import snakebite
When i am importing the same in HDFS.py file having following lines
import snakebite
from snakebite.client import Client
client = Client('localhost', 9000)
it causes following stack error:
============ RESTART: D:/Utkarsh/Python Projects/HDFS.py ============
Traceback (most recent call last):
File "D:/Utkarsh/Python Projects/HDFS.py", line 1, in <module>
import snakebite
ModuleNotFoundError: No module named 'snakebite'
sys.path had following values:
D:/Utkarsh/Python Projects
D:\Utkarsh\Installation\Lib\idlelib
D:\Utkarsh\Installation\python36.zip
D:\Utkarsh\Installation\DLLs
D:\Utkarsh\Installation\lib
D:\Utkarsh\Installation
D:\Utkarsh\Installation\lib\site-packages
Being newbie,can anybody help me in knowing exact cause of it.

Categories