6

I've just installed a Python package using pip:

$ sudo pip install py_vollib
Password:
Collecting py_vollib
  Downloading py_vollib-1.0.1.tar.gz
Collecting py_lets_be_rational (from py_vollib)
  Downloading py_lets_be_rational-1.0.1.tar.gz
Requirement already satisfied: simplejson in /Library/Python/2.7/site-packages (from py_vollib)
Requirement already satisfied: numpy in /Library/Python/2.7/site-packages (from py_vollib)
Collecting pandas (from py_vollib)
  Downloading pandas-0.20.3-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (15.0MB)
    100% |████████████████████████████████| 15.1MB 54kB/s
Requirement already satisfied: scipy in /Library/Python/2.7/site-packages (from py_vollib)
Requirement already satisfied: pytz>=2011k in /Library/Python/2.7/site-packages (from pandas->py_vollib)
Requirement already satisfied: python-dateutil in /Library/Python/2.7/site-packages (from pandas->py_vollib)
Requirement already satisfied: six>=1.5 in /Library/Python/2.7/site-packages (from python-dateutil->pandas->py_vollib)
Installing collected packages: py-lets-be-rational, pandas, py-vollib
  Running setup.py install for py-lets-be-rational ... done
  Running setup.py install for py-vollib ... done
Successfully installed pandas-0.20.3 py-lets-be-rational-1.0.1 py-vollib-1.0.1

and I've verified it's installed correctly:

$ pip freeze | grep vollib
py-vollib==1.0.1

but I can't import it in Python:

$ python
Python 2.7.13 (default, Jul 20 2017, 18:14:09)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import py_vollib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named py_vollib

Does anybody know what I'm doing wrong here?

[EDIT]

I've checked out help('modules'), which also shows the py_vollib package:

enter image description here

kramer65
  • 50,427
  • 120
  • 308
  • 488
  • 2
    Do you have multiple Pythons installed on your machine? It's possible that the `pip` appearing first in your PATH is associated with a different python than what appears first in your PATH. I would compare the output of things like `pip --version`, `which pip`, and `which python` and make sure they all point to the same location. Also, take a look at the site-packages directory for your Python and make sure there is a directory for py_vollib. – Gabe Hackebeil Aug 13 '17 at 04:25
  • @GabeHackebeil - I had a look at it, but even when check out the output of `help('modules')` from Python `py_vollib` is in there (see edited question). So that should tell me it's available in the `Python ` I use right? – kramer65 Aug 13 '17 at 04:39

1 Answers1

1

you are doing sudo pip install py_vollib which is installing the library in your root env.

If you are doing import py_vollib in ipython notebook or something, the module won't be available.

Try sudo python and then do the import

Or

do pip install py_vollib and then do python and try import py_vollib

Vikash Singh
  • 13,213
  • 8
  • 40
  • 70