importing wrong module in script - python

I am trying to import this module, exactly as per the documentation
from pytrends.request import TrendReq
I get the below error. It's trying to import the requests module, not pytrends.request
How can I get around this?
ModuleNotFoundError: No module named 'requests.packages.urllib3.util.retry'; 'requests.packages.urllib3.util' is not a package

First,
pip install requests lxml pandas
Also, make sure that you have installed pytrends as the comment suggests.
pip install pytrends
Also, make sure there no conflicts between conda and your default ecosystem.

Related

No module named 'polyglot.text'; 'polyglot' is not a package

I am new in python and I am trying to import polyglot module in my code. I have installed polyglot explained in Polyglot Installation, everything went good but it still gives me the same error.
ModuleNotFoundError: No module named 'polyglot.text'; 'polyglot' is not a package
When I checked polyglot in my drive, it has been installed inside directory
D:\Anaconda\Lib\site-packages\polyglot-16.7.4-py3.7.egg\polyglot
which has all the needed function in my code.
I need to know where is the problem? and I need to solve it!
I need to import the following functions:
from polyglot.transliteration import Transliterator
from polyglot.mapping import Embedding
from polyglot.load import load_embeddings
Try installing:
pip install polyglot numpy morfessor pycld2 pyicu

ModuleNotFoundError: No module named 'pycountry' even though it is installed

I got this error from python ModuleNotFoundError: No module named 'pycountry'.
I imported the module using pip and pip3 and I've also tried running my code in terminal using python, python3, and IDLE.
Why doesn't python recognize the module? I'm receiving the same error about plotly and pandas as well.
import pycountry
import plotly.express as px
import pandas as pd
URL_DATASET = r'https://raw.githubusercontent.com/datasets/covid-19/master/data/countries-aggregated.csvā€© '
df1 = pd.read_csv(URL_DATASET)
list_countries = df1['Country'].unique().tolist()
d_country_code = {}
Open your command window and then use this code there.
pip install pycountry
This will install the whole package in your system, so whenever you import the module, it will not show an error.
This worked for me, I was facing the same issue while using it in Jupyter Notebook.
If you want more information please visit this page.
If you have Anaconda, try:
conda install -c conda-forge pycountry

Not able to import a module that is already installed

I am trying to import a module "requests" but it shows the following error
File "manager.py", line 12,
import requests
ModuleNotFoundError: No module named 'requests'
Then I also verified the pip list using
python -m pip list
and it includes the requests module. also when I try to import it in the python interpreter it successfully imports the module.
>>> import requests
when I try
pip install requests
its says Requirement already satisfied: requests in /usr/lib/python3.6/site-packages
How can I resolve his issue ???
Thanks in advance
Make sure that your sys.path variables are correct. I've messed up before where the "site-packages" path got removed and caused imports to get wonky.

ImportError: No module named pandas_datareader

I am trying to use the pandas data reader library.
I initially tried import pandas.io.data but this threw up an import error, stating I should be using
from pandas_datareader import data, wb
instead. Upon trying this I was greeted with
ImportError: No module named pandas_datareader
I have had a look around and have tried...
"pip install pandas_datareader"
"pip install python_datareader"
"pip install pandas-datareader"
Any help would be greatly appreciated
run this command pip install pandas-datareader and for more info documentation is here

Quandl is not being imported

I'm getting started for Machine learning using Python and would like to use Quandl for computing. I installed the Quandl using pip install Quandl and also, pandas using pip install pandas. Later, the import for pandas is successful, but, I couldn't import quandl. I get error as following,
`ImportError: No module named Quandl`
I use Python 2.7 and Quandl supports both 2 and 3 version of Python. How to do the import properly ?
Looking at the docs, it is lower case:
import quandl

Categories

Resources