I have problems importing basemap, even though I just installed it via pip install basemap. I've tried both with python2.7 and python3:
python3
>>> from mpl_toolkits.basemap import Basemap
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'mpl_toolkits'
python2.7
>>> from mpl_toolkits.basemap import Basemap
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.py", line 37, in <module>
import _geoslib
ImportError: libgeos_c.so.1: cannot open shared object file: No such file or directory
I'm on a ubuntu OS.
What worked for me on ubuntu:
sudo apt-get install libgeos-3.4.2
sudo apt-get install libgeos-dev
sudo pip install https://github.com/matplotlib/basemap/archive/master.zip
It worked for me in python3 with v3.1.2 of matplotlib:
sudo apt-get update -y
sudo apt-get install -y python3-mpltoolkits.basemap
Check matplotlib module version running in python:
>>>import matplotlib
>>>matplotlib.__version__
'3.1.2'
Upgrade module:
sudo pip3 install matplotlib --upgrade
Related
I am taking a course that uses a racecar simulator and I need to run some pre-built code that uses a custom library and also numpy. When I try to run the code on Ubuntu I get the following error:
Traceback (most recent call last):
File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/numpy/core/__init__.py", line 22, in <module>
from . import multiarray
File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/numpy/core/multiarray.py", line 12, in <module>
from . import overrides
File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/numpy/core/overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "demo.py", line 16, in <module>
import racecar_core
File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/racecar_core.py", line 13, in <module>
import camera
File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/camera.py", line 11, in <module>
import numpy as np
File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/numpy/__init__.py", line 150, in <module>
from . import core
File "/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs/../library/numpy/core/__init__.py", line 48, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.8 from "/usr/bin/python3"
* The NumPy version is: "1.21.2"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
I have tried all the other potential duplicates that I could find and used the link but none worked. I have also tried uninstalling and reinstalling and updating numpy to no avail.
The output of running the command echo $PATH was the following:
/home/seb/.local/bin
:/usr/local/sbin
:/usr/local/bin
:/usr/sbin
:/usr/bin
:/sbin
:/bin
:/usr/games
:/usr/local/games
:/mnt/c/Program Files/WindowsApps/CanonicalGroupLimited.UbuntuonWindows_2004.2021.825.0_x64__79rhkp1fndgsc:/mnt/c/Program Files/Java/jdk-13.0.1/bin.
:/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath
:/mnt/c/Program Files (x86)/Common Files/Intel/Shared Libraries/redist/intel64/compiler:/mnt/c/WINDOWS/system32
:/mnt/c/WINDOWS
:/mnt/c/WINDOWS/System32/Wbem
:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/
:/mnt/c/WINDOWS/System32/OpenSSH/
:/mnt/c/Users/seb/anaconda3
:/mnt/c/Users/seb/anaconda3/Library/mingw-w64/bin
:/mnt/c/Users/seb/anaconda3/Library/usr/bin
:/mnt/c/Users/seb/anaconda3/Library/bin
:/mnt/c/Users/seb/anaconda3/Scripts
:/mnt/c/Users/seb/AppData/Local/Microsoft/WindowsApps
:/snap/bin
The output of running the command python3 -m site was the following:
sys.path = [
'/mnt/c/Users/seb/documents/Racecar/racecar-seb-h-s/labs',
'/usr/lib/python38.zip',
'/usr/lib/python3.8',
'/usr/lib/python3.8/lib-dynload',
'/home/seb/.local/lib/python3.8/site-packages',
'/usr/local/lib/python3.8/dist-packages',
'/usr/lib/python3/dist-packages',
]
USER_BASE: '/home/seb/.local' (exists)
USER_SITE: '/home/seb/.local/lib/python3.8/site-packages' (exists)
ENABLE_USER_SITE: True
This has happened to me as well because I am taking the same course. I solved it by uninstalling all the libraries and installing them again. Here is the link to the setup instructions: https://mitll-racecar-mn.readthedocs.io/en/latest/gettingStarted/computerSetup/python.html. These are the commands you have to run to install the libraries:
sudo apt update
sudo apt install python3.8
sudo apt install python3-pip
pip3 install --upgrade pip
pip3 install numpy
pip3 install matplotlib
pip3 install mypy
pip3 install nptyping
pip3 install opencv-contrib-python
pip3 install jupyter
pip3 install ipywidgets
jupyter nbextension enable --py widgetsnbextension
I installed pip3 using sudo apt-get install python3-pip after that when I run the following command to install django sudo pip3 install django I get this error:
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in
from pip import main
File "/usr/lib/python3/dist-packages/pip/init.py", line 14, in
from pip.utils import get_installed_distributions, get_prog
File "/usr/lib/python3/dist-packages/pip/utils/init.py", line 23, in
from pip.locations import (
File "/usr/lib/python3/dist-packages/pip/locations.py", line 9, in
from distutils import sysconfig
ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/init.py)
How do I fix this?
I have tried recently manually installing python3.9 version in my Ubuntu from 3.6 version using apt install python3.9. Then pip3 was broken. The issue is because distutils were not build for the 3.9 version.
So in my case I ran apt install python3.9-distutils to resolve my issue.
In your case make sure to modify 3.x version in distutils command.
This helped but then I got another error: ImportError: No module named 'pip._internal'
The following fixed it:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py --force-reinstall
I have installed Opencv on AWS ec2-instance using pip3 install opencv-python but while importing cv2 it throws an error
import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib64/python3.7/site-packages/cv2/__init__.py", line 5, in
<module>
from .cv2 import *
ImportError: libSM.so.6: cannot open shared object file: No such file or
directory`
I have also tried to download some modules using below command to solve the issue but it also not working
sudo yum install -y libsm6 libxext6 libxrender-dev`
sudo yum install libXtst
I am absolutely new to python and tried to install Theano.
Therefore I ran $ pip install numpy scipy.
Pip seems up to date but I always get the same error:
Collecting scripy
Using cached Scripy-0.9.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/lk/v92bv9gs51x55nwp0cspt3xw0000gn/T/pip-build-ZdGtpP/scripy/setup.py", line 96, in <module>
description=get_description(packages[0], PACKAGE_DIR),
File "/private/var/folders/lk/v92bv9gs51x55nwp0cspt3xw0000gn/T/pip-build-ZdGtpP/scripy/setup.py", line 47, in get_description
pkg = __import__(package, level=1)
File "/private/var/folders/lk/v92bv9gs51x55nwp0cspt3xw0000gn/T/pip-build-ZdGtpP/scripy/lib/scripy/__init__.py", line 11, in <module>
from .edit import *
File "/private/var/folders/lk/v92bv9gs51x55nwp0cspt3xw0000gn/T/pip-build-ZdGtpP/scripy/lib/scripy/edit.py", line 18, in <module>
import yamlog
ImportError: No module named yamlog
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/lk/v92bv9gs51x55nwp0cspt3xw0000gn/T/pip-build-ZdGtpP/scripy/
What am I doing wrong?
Thanks a lot!
No, you must have typed:
pip install numpy scripy # <-- should be `scipy`
You can see clearly from the output it is attempting to install scripy not scipy. Whatever this scripy pip package is, it clearly doesn't define its dependencies properly.
You didn't specify distribution and version but if you have python 2.7 I guess this might work.
sudo apt-get install python-numpy python-scipy python-dev python-pip python-nose g++ libopenblas-dev git
sudo pip install Theano
I have just started to use Tensorflow and I have done "hello world" with my test.py file. Moving on to next step, I started to do tutorial(https://www.tensorflow.org/versions/master/tutorials/mnist/beginners/index.html).
This is what I have done
$ git clone https://github.com/tensorflow/tensorflow
and run the file of "fully_connected_feed.py "
python tensorflow/examples/tutorials/mnist/fully_connected_feed.py
I got the error like
Traceback (most recent call last):
File "tensorflow/examples/tutorials/mnist/fully_connected_feed.py",
line 27, in
from tensorflow.examples.tutorials.mnist import input_data
ImportError: No module named examples.tutorials.mnist
so I changed code from
from tensorflow.examples.tutorials.mnist import input_data
from tensorflow.examples.tutorials.mnist import mnist
to
import input_data
import mnist
but I got error again.
Traceback (most recent call last):
File "tensorflow/examples/tutorials/mnist/fully_connected_feed.py", line 27, in
import input_data
File
"/Users/naggi/Documents/ML/tensorflow/tensorflow/examples/tutorials/mnist/input_data.py", line 29, in
from tensorflow.contrib.learn.python.learn.datasets.mnist import read_data_sets
ImportError: No module named contrib.learn.python.learn.datasets.mnist
Could someone help me?
Thanks
Install via pip :
$ sudo apt-get install python-pip python-dev
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl
update pip to latest version
sudo easy_install --upgrade six
sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py2-none-any.whl
It works for Mac os