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

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.

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

Adding libraries in Spyder

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

Pandas not working even though its installed

I've installed python and pandas using the Anaconda library, but it doesn't work when I try to import pandas in Jupyter Notebook or in the Python Idle. It does work when I run the shell in the terminal.
I am using macOS Mojave and Python version 3.7.6.
In the terminal, it says I have pandas already installed as you can see below.
However, I get the error message "ModuleNotFoundError: No module named 'pandas'" when trying to import it in the Python Idle as you can see below.
I think I know where the problem comes from but I don't know how to troubleshoot or fix it. I installed Anaconda 2 years ago and used it but deleted it when I was done with it to make space in my computer and now I reinstalled it. So I think the Idle and Jupyter Notebook are using a different version of Python than the one that came in the Anaconda package. I might be completely wrong.
Thank you for your help!
You probably haven't installed pandas in the same environment your Jupyter kernel is running in.
You can install it directly from Jupyter notebook by running !pip install pandas. That will install it in the environment that the kernel started in.
In general, running !pip freeze from jupyter notebook should show you all installed libraries. If pandas is not there after you ran !pip install pandas, your environment paths are broken in some big way.
In that case, I'd suggest nuking anaconda and jupyter installation and starting again.
If you want to know more about kernels and how packages work in them https://biasandvariance.com/importing-packages-in-jupyter-notebook/ could help.
If you want to use Anaconda, then just do:
conda install pandas
Mixing conda and pip may cause issues.
Can you try updating pandas?
pip install --upgrade pandas

ImportError PyCharm IDE

I am having trouble importing pandas, numpy and other modules into Pycharm. When I run python through ipython notebooks pandas, numpy, and other modules work fine. I am pretty sure this is a path problem. I have been to the Project interpreter settings in PyCharm to try to add the path where pandas and numpy are located on my computer, but I can't find the packages. I used easy_install and pip to install most of the packages, so I don't know where to find them. Any help will be very appreciated.

ImportError: No module named ... after spyder install

Anaconda Spyder is supposed to include numpy, scipy etc with the installation. Someone has installed Spyder for me on Windows 7 but if I try to import numpy or scipy , I get this error:
import numpy as np
ImportError: No module named numpy
I also can't run "conda" on the console.
What's wrong? What should I do to fix this? I tried adding PYTHONPATH in environment variables but no difference.
How can I check if they're even installed? I searched for NumPy in the computer, I only found the following:
It sounds like someone installed just spyder, not Anaconda, which is a separate thing (Anaconda is a collection of several Python packages, including Spyder, NumPy, and SciPy). Try downloading and installing Anaconda and using the Spyder that comes with that.
The thing is you have to install python 2.7. Surely you have a different python installed. If you download and install Python 2.7 this should works. Other thing you can do is search for the Anaconda Spyder version that support the Python you have installed.
It's probably that your the python core version of your spyder environment is different from the conda python version.
Python core version of your spyder environment
Conda python version
So you should make them of the same version then the problem will be solved.

Categories