'No module named 'pyhive'
I'm trying to access data from Hive in a iPython Notebook. So I run
pip3 install PyHive
This returns
Requirement already satisfied: PyHive in /usr/local/lib/python3.5/site-packages
But then when I run the following import
from pyhive import hive
I get the following error message
ImportError Traceback (most recent call last)
<ipython-input-4-747088b97eb4> in <module>()
----> 1 from pyhive import hive
ImportError: No module named 'pyhive'
Why can't I access pyhive when it's already installed.
Solution 1:[1]
It sounds like you have multiple instances of python installed on your computer. In order to change environments from one instance to another, you will need to activate the environment. If you're using conda, you can use the command
conda env list
which will list all of your installed environments. You can use a particular environment with
activate py2
"py2" is an example name, insert your own environment name. From there, you can find whether that particular instance has a PyHive installed with
pip list
if not, install it with pip or pip3.
Solution 2:[2]
I agree with Steltron in that there may be multiple python instances. If you don't have Anaconda (or even if you do), here is the general way to diagnose and fix the issue.
You can check the version of your default python interpreter with
python --version
If it is not python3 (likely python2), you can do a few things to correct it. I've listed two possible solutions below:
- Install PyHive for python2 if it is available.
- Add the python3 directory to your
PYTHONPATHin your.bashrcorprofilefile in the home directory. Then, activate python3 in the command line with some variant ofsource activate python3.
Solution 3:[3]
Worked for me:
pip install pyhive
Solution 4:[4]
For those who are still having the problem, I went to my python packages folder and found that PyHive was not there. so my solution was to install via pip straight from their official github directory. Follow the command:
python3 -m pip install git+https://github.com/dropbox/PyHive.git
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nate |
| Solution 2 | tooty44 |
| Solution 3 | Alon Hod |
| Solution 4 | Samuel Arao |
