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.
Related
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
I tried installing Rasterio library using command- pip install rasterio and also used conda commands in anaconda cmd, both are didn't worked and it's taking too long to install so I aborted the process. Let me know in detail how to install raserio library for python?
I tried with installing GDAL and raterio whl file by using pip commands. It got installed, but when I tried to import module- it's giving me an error saying No module found. Please help to fix this.
Thanks in advance
I just had the similar problem, and tl:dr the issue for me was multiple environments, like Ameya said. Here's a longer version of Ameya's spot-on answer with steps to diagnose and fix.
Without realizing it, I had two environments going on: my jupyter notebook was running python 3.10 and my global python was running 3.9, and each was looking for site-packages in different locations (/opt/homebrew/Cellar/jupyterlab/3.4.7/libexec/lib/python3.10/site-packages vs /Users//Library/Python/3.9/lib/site-packages).
This happened because I had trouble with getting python and specifically jupyterlab running on Monterey and the only fix for me was using homebrew to manage the packages. Anything I installed with brew from the command line, went into /opt/homebrew/Cellar... etc and could be seen by my jupyter notebook. Anything I used pip install to get from within an open notebook also went onto this path that my notebook could see. But anything I used pip install from the command line to get, went to the path of the global environment's site packages. Then, my jupyter notebook couldn't see them.
You don't mention that you are using jupyter notebook but perhaps something analogous could happen between multiple environments for you.
You can check if this is the case for you by doing the following:
start python from the command line
import sys
run sys.path
start jupyter notebook, or start python from your other environment
same thing, import sys, run sys.path
Are they the same? If not, probably pip is putting your rasterio in other python env site-packages.
To fix, you can either pip install from within your preferred environment, or copy and paste the site packages corresponding to rasterio from one site-packages location to the other.
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.
I have install PyautoGui without any errors on my Windows 7 machine. When I am importing pyautogui, it is giving me "ImportError: No module named 'pyautogui'" error. I am using Python 3.6.0a1 shell.
I am a new bee at python, so your help will be much appreciated.
I have other versions of python before which I uninstalled and then reinstalled 3.6. Their folders are still in C drive. Thank you.
Look into Tim Reilly's blog.
You have a couple of environments which means you may not have pyautogui installed in Python 3.6.
Virtual environments mitigate this because you can run multiple versions of Python with different packages installed. Once you have an environment setup,
mkvirtualenv environmentName
workon environmentName
you can install a given package and ensure that you have a relatively standardized setup.
Alternatively, use something like pip install to make sure you have installed (or reinstall) this in your current python environment.
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.