how to solve Module not found error? ( installed the module and error persists) - pip

I have installed the module tradingeconomics on cmd and when i try to import the library it throws this error , how to solve it ?
'
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-15897cf55e0a> in <module>
1 #Importing required libraries
----> 2 import tradingeconomics as te
3 import pandas as pd
4 import numpy as np
5 from datetime import datetime,date,timedelta
ModuleNotFoundError: No module named 'tradingeconomics'

It is possible that you installed the module in an environment and you are not working in the environment, or you are working in an environment but the module was installed outside of the environment. I use a conda environment, you can set up one by typing this in the terminal
conda create --new myenv
conda activate myenv
set up pip using the following
conda install -n myenv pip
then you can download modules
pip install tradingeconomics
use conda deactivate to exit the environment,
you can learn more about conda here https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#using-pip-in-an-environment

Related

Visual Studio Code ModuleNotFoundError: No Module Named Seaborn

can you help me out with this
I'm trying to import seaborn as sns
but on my screen, it just showed
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'seaborn'
I tried to uninstall then re-installed seaborn on anaconda so many times but it doesn't work
Thank you for your help
Please, check if, in VSCode, you are using the Python environment in which you installed Seaborn. Refer to this post. You may be using a Python environment that is not from Anaconda.
You may also try to install the package via VSCode, using the normal conda or pip commands as they tell here. In this case, the package is installed in the environment in use.

Python3 cannot find statsmodels.api but I can and so can my linter

I recently got into development with Python running on WSL (Ubuntu 18.04 LTS).
I followed the documentation from here and I'm able to run simple python scripts.
I started playing around with libraries that I installed using the pip3 command such as numpy and pandas and these work fine.
The problem arises when I try to use the statsmodels package.
I've installed it using pip3 install statsmodels
I can see the package in /home/username/.local/lib/python3.6/site-packages/statsmodels I can even see the api.py file in that directory, however, when I type import statsmodels.api as sm as recommended on the statsmodels website I get:
Console output:
username#DESKTOP-1JP4BIE:/mnt/c/users/username/dev/project/playground$ python3 statsmodels.py
Traceback (most recent call last):
File "statsmodels.py", line 5, in <module>
import statsmodels.api as sm
File "/mnt/c/username/chris/dev/project/playground/statsmodels.py", line 5, in <module>
import statsmodels.api as sm
ModuleNotFoundError: No module named 'statsmodels.api'; 'statsmodels' is not a package
I've tried uninstalling and reinstalling (did not work)
I really can't see anything that differentiates this package from the others that I've installed. Does anyone have any insights?
Thanks #Vorsprung durch Technik
The issue was that my file name was statsmodels.py.
I'll remember to be more careful when naming my python files.

ModuleNotFoundError for 'modin' even though it is installed by poetry

On import modin.pandas as modin_pd line I get ModuleNotFoundError: No module named 'modin'. I am using poetry & JupyterLab. If in the cell I type !poetry add modin, I get ValueError saying Package modin is already present.
So it cannot install modin because it is already installed but it cannot import it either. Any obvious solution that I am missing?
pip freeze command also shows modin to be installed. I also tried to install it via pip install but absolutely nothing let me to import this module in the end.
The problem may be this one KeyError: CPU
It can be solved by using pip install psutil

Conda does not set up properly path for JDK for pyjnius

I have installed pyjnius with conda. However, when I try to import pyjnius it fails
> from jnius import autoclass
File
"C:\Users\OEM\Miniconda3\envs\example-env\lib\site-packages\jnius\__init__.py",
line 12, in <module>
from .jnius import * # noqa ImportError: DLL load failed: The specified module could not be found.
Together with pyjnius conda installs also openjdk. Next, pyjnius looks for jvm.dll in one of PATH directories. DLL could be found in
C:\Users\OEM\Miniconda3\pkgs\openjdk-11.0.1-1017\Library\bin\server
but conda does not include it in PATH. It adds another folder in PATH:
C:\Users\OEM\Miniconda3\envs\example2-env\Library\jre\bin\server
while this directory is missing: JRE has not been installed, only JDK. I can, obviously, include first directory in my PATH, however, this would bypass conda virtual environments concept. How can I solve this problem in an elegant way?
Here's environment.yml to reproduce the problem:
name: example-env
channels:
- conda-forge
dependencies:
- python=3.7
- Cython
- pyjnius
Next, I create and activate as follows:
conda env update --file environment.yml
conda activate example-env

Pandas_datareader error in jupyter_notebook cannot find module via anaconda or pip, possible typo in package name?

There is a thread similar to my question, but mine is slightly different.I am using anaconda to run an environment with all the packages I am using. Running in python 3.7. I run jupyter notebook but the following gives me an error:
import pandas_datareader.data as web
Error:
ModuleNotFoundError Traceback (most recent call
last) in
----> 1 import pandas_datareader.data as web
ModuleNotFoundError: No module named 'pandas_datareader'
I noticed when I installed this module via anaconda:
conda install -c anaconda pandas-datareader
there is a hyphen in the module name (pandas-datareader) but when running import (above) there is an underscore. Could this be the problem?
I tried installing via pip and same error!

Resources