I'm installing google-auth on raspberry pi 3 using pip:
pip install google-auth
pip install --upgrade google-auth
But when I used import google.auth, I get the following error No module named 'google.auth'
(env) pi#raspberrypi:~/Desktop $ python
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linu
Type "help", "copyright", "credits" or "license" for more information
>>> import google.auth
Traceback (most recent call last)
File "<stdin>", line 1, in <module
ImportError: No module named 'google.auth
If you have installed pip by sudo,then try installing it using:
sudo pip install google-auth
Related
I am using Anaconda Python and used the following to install jpype:
conda install -c conda-forge jpype1
I have GCC installed:
Python 3.6.1 |Anaconda 4.4.0 (x86_64)| (default, May 11 2017, 13:04:09)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
and I did not get any error during installation.
conda install -c conda-forge jpype1
Collecting package metadata: done
Solving environment: done
# All requested packages already installed.
If I run pip search jpype I will get the following:
jtypes.jpype (0.6.3b3) - A Python to Java bridge (ctypes/cffi-based JPype).
JPype1-py3 (0.5.5.2) - Python-Java bridge. Fork of the jPype project by Steve Menard (http://jpype.sourceforge.net/), with the modifications applied by Luis Nell
(https://github.com/originell/jpype)
but still cannot call the library
>>> import jpype
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'jpype'
It might be because it is installed as a Python 2 package and you're running Python 3 or the opposite.
To specifically install the package for Python 3, try entering this command:
pip3 install jpype1
or
python3 -m pip install jpype1
To specifically install the package for Python 2, try entering this command:
pip2 install jpype1
or
python -m pip install jpype1
I found the problem.
By mistake, I had two versions of Anaconda 3.6 and 3.7 which was causing the problem.
I have an AWS EC2 p2.xlarge instance running on Ubuntu 16.04.4 LTS that was created using the AWS Deep Learning AMI (DLAMI). I am using the keras/Tensor Flow conda environment:
$ source activate tensorflow_p36
I am attempting to install Rasterio and GDAL on top of the Keras - Tensor Flow AMI installations using these commands (source):
$ sudo add-apt-repository ppa:ubuntugis/ppa
$ sudo apt-get update
$ sudo apt-get install python-numpy gdal-bin libgdal-dev
$ pip install rasterio
The GDAL install seems to work:
$ gdalinfo --version
GDAL 2.1.3, released 2017/20/01
However, when I try to import rasterio in Python, it yields the following error:
(tensorflow_p36) ubuntu#ip-171-11-7-03:~$ python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import rasterio
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ubuntu/anaconda3/envs/tensorflow_p36_test/lib/python3.6/site-packages/rasterio/__init__.py", line 15, in <module>
from rasterio._base import (
ImportError: /usr/lib/libgdal.so.20: undefined symbol: sqlite3_column_table_name
>>>
How can I clear this error so that I can import and use rasterio in Python?
I had a similar issue trying to import rasterio with GDAL 2.x installed. You should try to install GDAL 1.11 instead.
sudo pip3.6 install pafy
Collecting pafy
Downloading pafy-0.5.3.1.tar.gz
Installing collected packages: pafy
Running setup.py install for pafy ... done
Successfully installed pafy-0.5.3.1
It is Successfully installed pafy-0.5.3.1.
~$ python
Python 3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:09:58)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pafy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pafy'
Why no module named 'pafy'?
You ran pip as sudo but you're running python as normal user. Programs run as normal user don't have rights to access super-user's content (sudo).
To verify this, you can run python as super-user and try to import pafy.
$ sudo python
>>> import pafy
You should never use sudo pip install; you could overwrite important stuff.
Use pip install --user <packagename> or install and use virtualenv. I prefer virtualenv.
pip install pafy
This would work
system:ubuntu14.04, mysql:5.5, python:2.7.4
I have installed mysql-connector-python outside of a virtualenv using this command:
pip install mysql-connector-python --allow-external mysql-connector-python
I can use mysql-connector correctly outside of the virtualenv:
think#think-Inspiron-N4050:~$ python
Python 2.7.6 (default, Jun 22 2015, 18:00:18)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql.connector
>>>
>>>
then I activated a virtualenv and installed the mysql-connector. I used this method(I downloaded this install package from the offical website):
think#think-Inspiron-N4050:~/myzone/MindFly$ source venv/bin/activate
(venv)think#think-Inspiron-N4050:~/myzone/MindFly$ cd ~/download/
(venv)think#think-Inspiron-N4050:~/download$ dpkg -i mysql-connector-python_2.0.4-1ubuntu14.04_all.deb
After installed it correctly, I can not import it:
(venv)think#think-Inspiron-N4050:~/download$ python
Python 2.7.6 (default, Jun 22 2015, 18:00:18)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql.connector
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named mysql.connector
I don't know why, then I had to install MySQLdb inside the virtualenv:
(venv)think#think-Inspiron-N4050:~/myzone/MindFly$ sudo apt-get install python-mysqldb
after finished it, I can not import it too
(venv)think#think-Inspiron-N4050:~/myzone/MindFly$ python
Python 2.7.6 (default, Jun 22 2015, 18:00:18)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named MySQLdb
then I installed MySQL-python and libmysqlclient-dev, it alse didn't work.
then I looked over the venv/lib/python2.7/site-packages:
(venv)think#think-Inspiron-N4050:~/myzone/MindFly/venv/lib/python2.7/site-packages$ ls
easy_install.py pip-7.1.2.dist-info wheel
easy_install.pyc pkg_resources wheel-0.24.0.dist-info
_markerlib setuptools
pip setuptools-18.2.dist-info
there are not mysql-connector or mysqldb, I find mysqlconnector in /usr/lib/python2.7/dist-packages when I tried to reinstall mysqlconnector,
(venv)think#think-Inspiron-N4050:~/myzone/MindFly$ sudo pip install mysql-connector-python --allow-external mysql-connector-python
[sudo] password for think:
Requirement already satisfied (use --upgrade to upgrade): mysql-connector-python in /usr/lib/python2.7/dist-packages
Cleaning up...
I really don't know how to do after I install mysql-connector-python,mysqldb,mysql-python and libmysqlclient-dev. I can use them outside of the virtualenv, but I still can not import mysql-connector nor mysqldb in virtualenv.
Please help me: how can I connect mysql in virtualenv? thanks very much. (if the expression is not clear, tell me and I will update it,thanks)
then I activated a virtualenv and installed the mysql-connector (...)
dpkg -i mysql-connector-python_2.0.4-1ubuntu14.04_all.deb
(...)
then I had to install MySQLdb inside the virtualenv:
sudo apt-get install python-mysqldb
Err... apt-get and dpkg are your distrib's package manager, this has nothing to do with pip and virtualenv. Your distrib's package manager installs system packages (.deb in your case) and install them system-wide. The point of virtualenv is to install python packages (with pip) in an isolated "virtual" environnement. What you want is:
# source path/to/your/venv/bin/activate
# pip install your-python-package
Note that all this is documented in virtualenv and pip...
I need to import osgeo.ogr module to virtualenv python program.
Global python has this module:
user#ubuntu:~/$ python
Python 2.7.8 (default, Oct 20 2014, 15:05:19)
[GCC 4.9.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import osgeo
>>>
But into virtualenv (without --no-site-packages):
user#ubuntu:~$ temp/bin/python
Python 2.7.8 (default, Oct 20 2014, 15:05:19)
[GCC 4.9.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import osgeo
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named osgeo
What is the reason for this behavior?
Able to solve with this one
pip install --global-option=build_ext --global-option="-I/usr/include/gdal" GDAL==`gdal-config --version`
Problem is solved in this way:
(VIRTUAL_ENV)user#ubuntu:~$ pip install --no-install GDAL==1.11.2
1.11.2 because my version GDAL is 1.11.2:
(VIRTUAL_ENV)user#ubuntu:~$ gdal-config --version
1.11.2
next:
(VIRTUAL_ENV)user#ubuntu:~$ cd ~/.virtualenvs/VIRTUAL_ENV/build/GDAL/
(VIRTUAL_ENV)user#ubuntu:~/.virtualenvs/VIRTUAL_ENV/build/GDAL$ python setup.py build_ext --include-dirs=/usr/include/gdal/
(VIRTUAL_ENV)user#ubuntu:~/.virtualenvs/bamap/build/GDAL$ pip install --no-download GDAL
--include-dirs=/usr/include/gdal/ for me is correct. GDAL was installed with Quantum GIS in my system. If you will build GDAL manually paths may be others. Full version:
python setup.py build_ext --gdal-config=/YOUR_PATH/bin/gdal-config --library-dirs=/YOUR_PATH/gdal/VERSION_GDAL/lib --libraries=gdal --include-dirs=/YOUR_PATH/gdal/VERSION_GDAL/include
Details may find here.
sudo add-apt-repository ppa:ubuntugis/ppa && sudo apt-get update
if you have facing the issue " Cannot import name '_gi' ":
visit this link to fix
sudo apt-get update
sudo apt-get install gdal-bin
sudo apt-get install libgdal-dev
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal
pip install GDAL==$(gdal-config --version) --global-option=build_ext --global-
option="-I/usr/include/gdal"