Adding libraries in Spyder - python

I installed the libraries I needed by using these commands below:
conda install matplotlib
conda install numpy
I see the '# All requested packages already installed.' in terminal. But when I try to run the code again, I get this warning: ModuleNotFoundError: No module named 'matplotlib.pylot'
Can somebody help me how to fix this problem?

This is likely occurring because the environment in which you installed the packages is not the one set as interpreter in spyder. See how to change interpreter in spyder here

Related

Spyder does not find gdal package even though it is installed

I have installed gdal with miniconda in the working environment for spyder. After restarting the PC, the conda list shows me that gdal is installed. However, I can not import the package.
"""Error: No module named 'gdal'"""
The PythonPath Manager did not solve the problem either. I have also manually installed georasters, which was recommended elsewhere.
Does anyone have an idea what the problem is? The problem is only with gdal. I have installed geopandas as a test and it works as it should.
Miniconda Terminal
You need to use
from osgeo import gdal
See documentation: https://gdal.org/api/python_bindings.html

How to install NetCDF4 module in Spyder?

I don't know why this is causing me so much headache.
I know how to use pip, and have the latest version, but still when running a script in Spyder that requires netCDF4 (import netCDF4) Spyder always returns:
import netCDF4
ModuleNotFoundError: No module named 'netCDF4'"
I opened cmd, pip install netCDF4, confirmed it installed OK. Shouldn't this be enough?
I manually copied a downloaded version of netCDF4, moved it to my Python site packages, and then in Spyder manually went into PYTHONPath Manager -> Add Path --> Added the folder location 'netCDF4-1.6.0'. I thought this would definitely be enough?
Then INSIDE Spyder's python console, bot-right of screen, I tried 'pip install netCDF4' and it returns:
Note: you may need to restart the kernel to use updated packages.
C:\...\Spyder\Python\python.exe: No module named pip
So is my issue #3? Spyder's version of Python doesn't have pip and doesn't link to the netCDF4 module? I thought my step #2 would resolve this?
Any help on how to install modules in Spyder would be appreciated, thank you!
Download Miniconda and install all the packages you want in a new environment. For example,
conda create -n myenv -c conda-forge python=3.9 netcdf4 [others ...]
Then follow the Spyder documentation for adding a conda environment.
Credit to Michael Delgado (above)

Own installed package not available in Spyder

I'm beginner in python, and I have to maintain a python code, which imports a self-made package.
I am able to install this package with pip, but somehow the Sypder(pyhton 3.9) does not accept it.
The error is: "ModuleNotFoundError: No module named 'myModule'
If I type the following command into the IPython console, then it says that the package is already installed.
pip install d:\MyFolder\myModule-0.2.0-py3-none-any.whl
Result:
Processing d:\MyFolder\myModule-0.2.0-py3-none-any.whl
myModule is already installed with the same version as the provided wheel. Use --force-reinstall to force an installation of the wheel.
Note: you may need to restart the kernel to use updated packages.
I already tried to solve this problem based this article: Spyder_modulenotfound
The packge is present in the Anaconda3 installation folder: d:\Anaconda3\Lib\site-packages\myPackage-0.2.0.dist-info\ and I added this folder into the PYTHONPATH manager tool. Already restarted the Spyder many times, still no change.
What am I missing? Please help...

Pandas / numpy are installed but cannot import. Have tried everything

I have uninstalled and re-installed numpy and pandas using pip (see photo) but in pycharm, they cannot be imported - "No module"
cmd
pycharm output
your help would be much appreciated
I sometimes get an error in PyCharm. Have you tried restarting PyCharm?
There are ways to solve the error:
Check the python environment where you installed numpy and pandas.
You can also create a virtual environment where you will install these libraries and activate this environment to pycharm.

Python, 'no module named {package}' error

I'm trying to use a package I installed using pip and it got installed in C:\Program Files\Python\Python38\Lib\site-packages, but when I import it in my IDE I get an error saying No module named instabot. I have had this error before and I'm unsure of what is happening
The problem might be that you are using a virtual environment in your IDE. If you using PyCharm, consider taking a look at this link.
Try pip or pip3 installing it in the right environment depending on your python version.

Categories