I've looked at many questions on this issue, but none seem to help. I am new to Python and programming. I am not sure if installing matplotlib is what I need to do, but it was the link given in my textbook (I am self studying, so there's no one I can ask).
I downloaded the newest version of Python, 2.7.10, and then went to here and followed the instructions.
In Terminal.app,
Installing collected packages: pip, wheel
Found existing installation: pip 6.1.1
Uninstalling pip-6.1.1:
Successfully uninstalled pip-6.1.1
Successfully installed pip-7.0.1 wheel-0.24.0
Yet when I run my code, which begins with:
import pylab
from rcParamsSettings import *
import random
I end up getting
ImportError: No module named pylab
Can someone please help me figure this out? I have no idea what to do now.
It looks like you ran the instructions to (re)install pip, but you did not yet run the instruction that uses pip to install matplotlib, i.e.:
pip install matplotlib
Related
I am Windows and using python through jupyternotebook.
python 3.9.7, windows 64 bit,
I want to import geopandas, so I used the code conda install --channel conda-forge geopandas. It seemed work at first because I could successfully import geopandas without error, but when I want to run the following code, an import error appears.
world = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))
world.columns
ImportError: the 'read_file' function requires the 'fiona' package, but it is not installed or does not import correctly.
Importing fiona resulted in: DLL load failed while importing ogrext
I saw other people asked the same questions, but none of their solutions worked. At first, I saw someone said nstalling geopandas by condas might installed wrong version of fiona and gdal. So I tried to update by conda update conda, and conda update -n base conda-package-handling and conda update --all. However, these code didn't work. Later, I directly installed the .whl file from python library: Fiona-1.8.20-cp39-cp39-win_amd64.whl and GDAL-3.4.1-cp39-cp39-win_amd64.whl, and use pip to install them. But the error still appeared.
I really have no idea how to deal with such issue, is it because the version of fiona and gdal was not consistent? Please give me some suggestions, thanks ahead!
I have solved this problem by creating a new environment followed this article: https://medium.com/analytics-vidhya/fastest-way-to-install-geopandas-in-jupyter-notebook-on-windows-8f734e11fa2b
This is the fast way to solve this problem.
I am trying to use the Python module Gdal. I have run pip install gdal and I recieve the message
Requirement already satisfied: gdal in c:\users\willy\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (3.3.1)
and yet when I run import gdal in my Python IDE (I use Spyder), I still get the error no module named gdal
You need to tell Spyder which Python interpreter to use. Point it to the one you're installing the package for, as it seems that it's using a different one.
https://docs.spyder-ide.org/current/faq.html#using-existing-environment
From the documentation it seems you have to call:
from osgeo import gdal
See here
Answer is here in Spyder docs: https://docs.spyder-ide.org/5/faq.html#using-packages-installer
Don't try to use pip install and expect it to work in Spyder. Follow these instructions
I have been using Jupyter for some time now and it has worked just fine. I have Jupyter and Python installed via Homebrew. I am running on MacOS.
Yesterday, I ran the command brew upgrade and now my Jupyter notebook is unable to find any of the installed python packages. I will use Numpy as the example.
When inside of a Jupyter notebook, I try to do
import numpy
I get the message:
ModuleNotFoundError: No module named 'numpy'
If, however, I launch python in a terminal window, then I can import Numpy without issue.
I first checked that the package was installed correctly by re-issuing the install command
brew install numpy
which outputs:
Warning: numpy 1.18.4 is already installed and up-to-date
To reinstall 1.18.4, run `brew reinstall numpy`
I also ran
pip install numpy
and got:
Requirement already satisfied: numpy in /usr/local/lib/python3.7/site-packages (1.18.4)
Now, this is where I got confused because I expected the path to point to something like /usr/local/Cellar/, so I checked the path inside of the Jupyter notebook:
import sys
sys.path
which outputs:
['/Users/kseuro/Dropbox/Dev/',
'/usr/local/Cellar/jupyterlab/2.1.2/libexec/lib/python38.zip',
'/usr/local/Cellar/jupyterlab/2.1.2/libexec/lib/python3.8',
'/usr/local/Cellar/jupyterlab/2.1.2/libexec/lib/python3.8/lib-dynload',
'/usr/local/opt/python#3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8',
'',
'/usr/local/Cellar/jupyterlab/2.1.2/libexec/lib/python3.8/site-packages',
'/usr/local/Cellar/jupyterlab/2.1.2/libexec/lib/python3.8/site-packages/IPython/extensions',
'/Users/kseuro/.ipython']
Ok, so Homebrew wants Jupyter to use Python3.8? So I tried brew switch python 3.8 and got:
Error: python does not have a version "3.8" in the Cellar.
python's installed versions: 3.7.7
I feel like I'm out of my depth now and need help figuring out what to do next. I don't want to start by just changing paths around.
Suggestions? Thanks so much.
I figured out what to do — posting the solution for my future self and others who may stumble upon this.
Since Jupyerlab is in its own Cellar, the Python packages need to end up in the
/usr/local/Cellar/jupyterlab/x.y.z/libexec/lib/python3.x/site-packages
directory, where x, y, z are integers, so that the Jupyter kernel can find them.
You can do this by calling:
import sys
!{sys.executable} -m pip install 'package-name'
inside of the Jupyer notebook.
All is well, again.
I installed tensorflow CPU version in windows as mentined on their official page.
It got installed successfully but giving error while I import the library.
Output for pip freeze also shows it's present:
spyder==3.1.2
SQLAlchemy==1.1.5
statsmodels==0.6.1
sympy==1.0
tables==3.2.2
tensorflow==1.0.1
toolz==0.8.2
tornado==4.4.2
traitlets==4.3.1
Using anaconda.
If you have python 2.X installed along with a Python 3.X do pip(version) example; pip3 instead of pip. I had a similar problem so i had a look around and someone said do pip3.6.1 but it spewed out an error so a few trys later pip3 worked. If not idk whats happening
I was trying to use the lmfit package for doing nonlinear least squares fit and I notices that the Canopy curated version is really old and doesn't have most of the objects. So I followed the instructions here https://support.enthought.com/entries/23389761 as I have done before no problem:
pip install --upgrade setuptools
pip install --upgrade lmfit
Now when I execute the same exact code some "import" statements (I suppose those involved with scimath) give:
ImportError: cannot import name scimath
Seems python standard library imports are fine e.g. import os.
I'm on Ubuntu Linux 14 with Canopy 1.5.2
What happened and how can I fix it and avoid breaking it again.
I solved the problem but I am still not sure why this occurred originally. I went into the package manager and uninstalled scimath reinstalled it and did explicit kernel restarts on my IPython notebooks and interpreters. This fixed it but I don't see why unless somehow the scimath installation was corrupted. Before that I tried restarting application, computer, and reinstalling canopy.