ModuleNotFoundError after installing from github - numpy

I installed the OSMNX package from GitHub with pip using
pip install git+git://github.com/gboeing/osmnx.git
and I confirmed OSMNX was installed as it showed up on pip list.
However, when trying to import osmnx I receive an error that NumPy cannot be found. I definitely have NumPy installed, and I confirmed that NumPy shows up in pip list, so I'm not sure why OSMNX can't find NumPy. Any ideas on how to make OSMNX recognize NumPy?
Here's the full error

Related

How can I fix the error "Could not find a version that satisfies the requirement torch" when trying to install PyTorch using pip?

I tried importing 'PyTorch' as 'torch' as most recent, but visual studios/cmd cannot locate nor download the package.
# Import the required modules import torch import torch.nn as nn import torch.nn.functional as F
same goes with
import tensorflow as tk
I wasn't able to download the package:
not able to find the file.
I tried both:
pip install --upgrade pip
and:
pip install torch==1.0.2
I tried all types such the basic pip install [package] to connecting the wsl.file through path
Installing older torch needs --find-index flag to pip, like torch 1.5 with cuda 10.1:
pip install torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
Reference:
https://pytorch.org/get-started/previous-versions/

How to plot an image using PIL or Matplotlib

I am trying to plot an image in python using either PIL or Matplotlib. I have tried both
import matplotlib.pyplot as plt
and
from PIL import Image
But I get the same error:
ImportError: cannot import name '_imaging' from 'PIL'
I have updated pillow and matplotlib packages but no success
You can read the image using open cv and then plot it using matplotlib.
img_name = cv2.imread("image.jpeg")
plt.imshow(img_name)
plt.show()
This usually happens when folk use python and pip from different packages, distributions or versions. I mean you install a package with pip into one package/distribution/version and then try and use it from a different package/distribution/version of Python.
So, if you normally start Python using:
python
then run:
type python
Whereas if you normally start Python using:
python3
then run:
type python3
On my machine I get:
type python3
python3 is /Library/Frameworks/Python.framework/Versions/3.9/bin/python3
so now I know which Python I am using.
Now you need to see which pip you are using. So, if you normally start pip with:
pip
then run:
type pip
Whereas if you normally start pip with:
pip3
then run:
type pip3
On my machine I get:
type pip3
pip3 is /Library/Frameworks/Python.framework/Versions/3.9/bin/pip3
So now you can see that my pip3 is installing packages for python3 exactly where it can find them.

Pandas incompatible with numpy

I am using anaconda 3. When I try to import pandas I receive the following message:
ImportError: this version of pandas is incompatible with numpy < 1.15.4
your numpy version is 1.15.3.
Please upgrade numpy to >= 1.15.4 to use this pandas version
Printing numpy.__path__ gives me the following
['C:\Users\andrei\AppData\Roaming\Python\Python37\site-packages\numpy']
In conda list, my numpy version is 1.19.1. I checked the above directory to find that it has only numpy 1.15.3 inside and nothing else. Spyder is using this path instead of the anaconda's path to numpy for some arcane reason.
Looks like you have somehow installed several versions of NumPy. Try to remove them all by running several times conda remove numpy and pip uninstall numpy. If you have two versions, the corresponding uninstall command needs to be run twice. After these, install a fresh version of NumPy conda install numpy
You can verify if you still have a version of NumPy installed
conda list | grep numpy
pip list | grep numpy
Note that these commands show only one version number even if you have several copies installed.
You can use conda to upgrade to upgrade your numpy. Run this command in the terminal:
conda update numpy
You need to remove this directory
C:\Users\andrei\AppData\Roaming\Python\
to fix this problem. It seems at some point you used pip to install numpy and that's interfering with the packages installed by conda (which is reporting the right version, as you said).
Furthermore, please be aware that pip and conda packages are binary incompatible, so you should avoid as much as possible to mix them.

Install GeoViews on a Google Colaboratory Notebook

Is it possible to install geoviews on a Google Colaboratory notebook so that I can use it to plot data from an Xarray Dataset?
Geoviews depends on cartopy, which has some additional requirements that aren't covered by pip. You can install them with apt, at which point the geoviews installation will work correctly:
!apt-get install libgeos++ libproj-dev
!pip install geoviews
After this, you can run a basic geoviews command:
import geoviews as gv
import geoviews.feature as gf
gv.extension('matplotlib')
gf.ocean
As newer versions of Cartopy seem to have trouble installing on Google Colab I find it best to specify a specific version of Cartopy before installing Geoviews. (0.18.0)
Also, Cartopy and Shapely (which is preinstalled on Google Colab) aren't friends... So uninstalling Shapely first and reinstalling it without binaries gives better Cartopy perfomance as well.
(Make sure to ignore shapely deprecation warnings as well)
# Uninstall existing shapely
# We will re-install shapely in the next step by ignoring the binary
# wheels to make it compatible with other modules that depend on
# GEOS, such as Cartopy (used here).
!pip uninstall --yes shapely
# To install cartopy in Colab using pip, we need to install the library
# dependencies first.
!apt-get install -qq libgdal-dev libgeos-dev
!pip install shapely --no-binary shapely
!pip install cartopy==0.18.0
#Install geoviews
!pip install geoviews
#Ignore shapely deprecations warnings
import warnings
warnings.filterwarnings('ignore')
Check it out yourself in this notebook:
https://colab.research.google.com/drive/1ZL6frd87sG4ErqGrI2mJZI9ix-FRMV62
Or check it out this working example of Geoviews in combination with Xarray in this notebook:
https://colab.research.google.com/drive/1sI51h7l-ySoW2bLrU-K1LMm-TYNVBlif

i cant import numpy in pycharm and its showing errors even after running pip install numpy in cmd

even after trying pip install numpy in cmd i cannot get the numpy module installed in pycharm.
i have also tried to add numpy using project interpreter.
numpy is being listed in the available modules but it cannot be installed.
The screenshot of the error is placed below. please help me out