ModuleNotFoundError: No module named 'tool' - python-3.x

from statsmodels.tsa.statespace.sarimax import SARIMAX
from math import sqrt
from sklearn.metrics import mean_absolute_error, mean_squared_error
from multiprocessing import Pool
from tool.utils import Util
I have downloaded Util, tools moule still it shows ModuleNotFoundError: No module named 'tool'

If you have multiple python installations, make sure you are installing the package for the correct python version. To install a package for python3.x use python3.x -m pip install {package}

Related

When try to run import pandas from Visual Studio Code it thrown an ImportError, but works fine in Anaconda (Jupyter Notebook)

I used to code in Jupyter notebook and importing pandas was never thrown an error. But when I use the same code in Visual Studio Code,
# Import Libraries
from random import seed
from random import randint
import pandas
import numpy
import math
import random
import collections
import itertools
import collections
import matplotlib.pyplot as plt
import seaborn as sns
# %matplotlib inline
I receive the below error.
File "g:/My Drive/M/importlibrary.py", line 5, in <module>
import pandas
File "C:\Users\M\Anaconda3\lib\site-packages\pandas\__init__.py", line 19, in <module>
"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
I try to search for several similar issues and most of the solution ask to first uninstall and then install NumPy and Pandas using the below code,
pip3 uninstall pandas
pip3 uninstall numpy
However, I have followed this workaround but the problem did not resolve. The version of python that I am using is,
Python 3.6.8 :: Anaconda, Inc.
Please help if you can.
Is there a reason why you don't install Numpy/Pandas using anaconda (conda install -c anaconda numpy/pandas)? Did you run Jupyter from inside anaconda when it worked? I suggest going to terminal and figuring out where your modules are installed (i.e. if they are inside the anaconda folders, or somewhere where anaconda has access to).
In general, I'd advise against installing python packages for anaconda using pip, just use conda's package manager if you can. This question seems related. In your case, have you tried uninstalling the pip variant and reinstalling using conda?
The problem is resolved by uninstalling the Anaconda. I checked the control panel of the PC and found that there are multiple instances of python. VS Code uses Python 3.6.8 while Anaconda uses python 3.8. So, I uninstall 3.8, and then reinstall pandas,
pip3 uninstall pandas
pip3 install pandas
The error is no more.

How can I install modules in Mac OS Terminal?

I want to install some modules for Telegram Bots and I always get errors like:
File "test.py", line 7, in <module>
import spotipy
ModuleNotFoundError: No module named 'spotipy'
I tried to install spotipy with pip, pip3 and apt.
How is it done? Or generally how do I import modules?
Thank you.
From the spotipy README:
If you already have Python on your system you can install the library simply by downloading the distribution, unpack it and install in the usual fashion:
python setup.py install
You can also install it using a popular package manager with
pip install spotipy
or
easy_install spotipy
Make sure your pip version matches your python version (pip --version and python --version should both be Python3 or Python2).
To import the module, use one of the following statements (see python3 documentation):
import numpy
import numpy as np
from numpy import array

Error that numpy library import is not available?

from numpy import *
from pylab import *
Why am I getting a warning next to both of these lines "unable to detect undefined names"
Because numpy module don't come with python standard library. you should first install numpy by using python pakage manager : pip
if you are in windows then you can run following command in cmd
pip install numpy
to install numpy and then you can import in your python file

No module named 'email.FeedParser'

I am trying to run a code on AWS Lambda but it is returning me the error: "Unable to import module 'main': No module named 'email.FeedParser'".
My code does not use email feedparser module or function. It just connect to one Google API and download a CSV report.
I've checked my code scope and the reference for this module is being done by httplib2 library and on the email/parser.py from the python standard library.
All required libraries are fully updated in requirements.txt file. The code is also configured by a samTemplate.yaml file to execute in a python 3.7 environment at aws.
Do you guys had experienced this problem before? How can I solve it?
Thank you!
import httplib2
from googleapiclient import discovery
from oauth2client.client import flow_from_clientsecrets
from oauth2client.file import Storage
from oauth2client.tools import run_flow
from urllib.parse import urlencode
import requests
import json
import time as t
import pandas as pd
from datetime import datetime, timedelta
from calendar import monthrange
from dateutil.relativedelta import relativedelta
I had to make sure pip3 was actually installing to python3 and not python2.
Instead of:
pip3 install <package>
I had to do:
python3.8 -m pip install <package>
See answer here: Why pip3 install in python2 sitepackages
I had exactly the same issue...
I did this:
vim ~/.pydistutils.cfg
[install]
prefix=
see here: 24257803 for more info on this step
rm -rf [dependencies_dir]
pip3 install -r requirements.txt --target [dependencies_dir]
Pip3 will install this dependencies to Python3, where pip was installing to Python2 (where some of these packages don't exist). So when deploying to Lambda via serverless the packages weren't included.

from ConfigParser import SafeConfigParser ImportError: No module named 'ConfigParser'

I am getting below error:
"from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser''
I am trying to install Mysql-python in python3 but not getting success.
The package is renamed to configparser for PEP 8 compliance and the package you are trying to install doesn't support Python 3.
You can use mysqlclient instead. You can install it using the below command:
pip install mysqlclient
Or one more alternative is there which I won't personally recommend, but just to share it:
# Install configparser
pip install configparser
# Rename it to ConfigParser
sudo cp /usr/lib/python3.6/configparser.py /usr/lib/python3.6/ConfigParser.py
After doing the above, you should be able to download MySQL-python without problems.
P.S: Answer is inspired by the answers to this question
In Python 2 this works:
from ConfigParser import SafeConfigParser
Python is case sensitive and in Python 3 the module was renamed to configparser So you would need import like this:
from configparser import SafeConfigParser
Looks like the library you trying to install is for Python 2. You need to get the Python 3 version.

Resources