3

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.

Stacker
  • 587
  • 4
  • 7
  • 11
  • 1
    Where is your python installed? is it in /usr/local/? You may be running another python from another distribution. – DYZ Jan 23 '17 at 23:29
  • In your notebook, what's the value of `sys.executable`? – eduffy Jan 23 '17 at 23:31
  • Yup that's not the path to the python I'm using. How do I change the sys.executable to point to the system Python 3. It's currently pointing to /Users/username/anaconda3/bin/python – Stacker Jan 24 '17 at 00:07
  • I am having this exact problem. I am not seeing a great solution anywhere. Was anyone able to fin a solution for this? – Pat Doyle May 05 '19 at 19:08

5 Answers5

3

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.

Nate
  • 2,113
  • 5
  • 19
  • 25
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:

  1. Install PyHive for python2 if it is available.
  2. Add the python3 directory to your PYTHONPATH in your .bashrc or profile file in the home directory. Then, activate python3 in the command line with some variant of source activate python3.
tooty44
  • 6,829
  • 9
  • 27
  • 39
1

Worked for me:

pip install pyhive

Alon Hod
  • 11
  • 1
1

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
0

This worked for me

python3 -m pip install git+https://github.com/dropbox/PyHive.git

or

python -m pip install git+https://github.com/dropbox/PyHive.git
Gabber
  • 7,169
  • 3
  • 32
  • 46