pip安装后的vollib问题

鲍里斯·L。

我已经安装了vollib模块,如下所示:

[root@E7440 boris]# python -m pip install vollib
Collecting vollib
  Using cached vollib-0.1.5.tar.gz
Requirement already satisfied: lets_be_rational in /usr/lib64/python2.7/site-packages (from vollib)
Requirement already satisfied: simplejson in /usr/lib64/python2.7/site-packages (from vollib)
Requirement already satisfied: numpy in /usr/lib64/python2.7/site-packages (from vollib)
Requirement already satisfied: pandas in /usr/lib/python2.7/site-packages/pandas-0.19.0-py2.7-linux-x86_64.egg (from vollib)
Requirement already satisfied: python-dateutil in /usr/lib/python2.7/site-packages (from pandas->vollib)
Requirement already satisfied: pytz>=2011k in /usr/lib/python2.7/site-packages (from pandas->vollib)
Requirement already satisfied: six>=1.5 in /usr/lib/python2.7/site-packages (from python-dateutil->pandas->vollib)
Installing collected packages: vollib
  Running setup.py install for vollib ... done
Successfully installed vollib-0.1.5

尽管安装似乎成功,但是vollib模块无法按预期运行:

[root@E7440 boris]# python
Python 2.7.11 (default, Sep 29 2016, 13:33:00) 
[GCC 5.3.1 20160406 (Red Hat 5.3.1-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import vollib
>>> c = vollib.black_scholes('c',100,90,.5,.01,.2) 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'black_scholes'
>>> dir(vollib)
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__']
>>> 

由于某些原因,black_scholes和其他属性(例如助手,black和black_scholes_merton)丢失或无法访问。

怎么了?

[root@E7440 boris]# python -m pip check
No broken requirements found.

那里没有发现问题...

vollib安装在哪里?

[root@E7440 boris]# python -m pip show vollib
Name: vollib
Version: 0.1.5
Summary: UNKNOWN
Home-page: http://vollib.org
Author: vollib
Author-email: [email protected]
License: MIT
Location: /usr/lib/python2.7/site-packages
Requires: lets-be-rational, simplejson, numpy, pandas

检查vollib位置:

[root@E7440 boris]# ll /usr/lib/python2.7/site-packages/vollib* -d
drwxr-xr-x. 7 root root 4096 Nov  5 17:16 /usr/lib/python2.7/site-packages/vollib
drwxr-xr-x. 2 root root 4096 Nov  5 17:16 /usr/lib/python2.7/site-packages/vollib-0.1.5-py2.7.egg-info
[root@E7440 boris]# tree /usr/lib/python2.7/site-packages/vollib
/usr/lib/python2.7/site-packages/vollib
├── black
│   ├── greeks
│   │   ├── analytical.py
│   │   ├── analytical.pyc
│   │   ├── __init__.py
│   │   ├── __init__.pyc
│   │   ├── numerical.py
│   │   └── numerical.pyc
│   ├── implied_volatility.py
│   ├── implied_volatility.pyc
│   ├── __init__.py
│   └── __init__.pyc
├── black_scholes
│   ├── greeks
│   │   ├── analytical.py
│   │   ├── analytical.pyc
│   │   ├── __init__.py
│   │   ├── __init__.pyc
│   │   ├── numerical.py
│   │   └── numerical.pyc
│   ├── implied_volatility.py
│   ├── implied_volatility.pyc
│   ├── __init__.py
│   └── __init__.pyc
├── black_scholes_merton
│   ├── greeks
│   │   ├── analytical.py
│   │   ├── analytical.pyc
│   │   ├── __init__.py
│   │   ├── __init__.pyc
│   │   ├── numerical.py
│   │   └── numerical.pyc
│   ├── implied_volatility.py
│   ├── implied_volatility.pyc
│   ├── __init__.py
│   └── __init__.pyc
├── helper
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── numerical_greeks.py
│   └── numerical_greeks.pyc
├── __init__.py
├── __init__.pyc
└── tests
    ├── __init__.py
    ├── __init__.pyc
    ├── test_black_scholes_greeks.py
    ├── test_black_scholes_greeks.pyc
    ├── test_black_scholes.py
    ├── test_black_scholes.pyc
    ├── test_data.json
    ├── test_utils.py
    └── test_utils.pyc

8 directories, 45 files

模块文件似乎存在...

检查所需的模块:

[root@E7440 boris]# python -m pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=legacy (or define a list_format in your pip.conf) to disable this warning.
apicaro (1.0)
arandr (0.1.9)
astroid (1.3.6)
Babel (1.3)
backports.ssl-match-hostname (3.5.0.1)
blivet (1.12.8)
cffi (1.4.2)
chardet (2.2.1)
Cheetah (2.4.4)
coverage (4.0.3)
cryptography (1.2.1)
cssselect (0.9.1)
Cython (0.23.4)
decorator (4.0.10)
dnf-langpacks (0.15.1)
docutils (0.12)
enum (0.4.4)
enum34 (1.0.4)
ethtool (0.11)
frescobaldi (2.19.0)
funcsigs (1.0.2)
gresistor (0.0.1)
gwebsockets (0.4)
humanize (0.5.1)
idna (2.0)
iniparse (0.4)
ipaddress (1.0.7)
IPy (0.81)
iwlib (1.2)
Jinja2 (2.8)
kitchen (1.2.1)
laditools (1.0.1)
langtable (0.0.34)
lets-be-rational (1.0.9)
logilab-common (0.63.2)
lxml (3.4.4)
MarkupSafe (0.23)
matplotlib (1.4.3)
meld (3.14.0)
mercurial (3.5.2)
mibian (0.1.3)
mock (2.0.0)
mutagen (1.29)
myhdl (0.8.1)
ndg-httpsclient (0.4.0)
nose (1.3.7)
ntplib (0.3.3)
numpy (1.9.2)
pandas (0.19.0)
pbr (1.10.0)
pdfshuffler (0.6.0)
pexpect (4.0.1)
Phatch (0.2.7)
Pillow (3.0.0)
pip (9.0.0)
ply (3.6)
progress (1.2)
protobuf (2.6.1)
ptyprocess (0.5.1)
pwquality (1.3.0)
pyalsa (1.0.29)
pyasn1 (0.1.8)
pyasn1-modules (0.0.6)
pycparser (2.14)
pycurl (7.19.5.1)
pyflakes (1.0.0)
PyGithub (1.25.2)
Pygments (2.1.3)
pygobject (3.18.2)
pygpgme (0.3)
pyinotify (0.9.6)
pykickstart (2.13)
pyliblo (0.9.1)
pyliblzma (0.5.3)
pylint (1.4.3)
PyOpenGL (3.1.0)
PyOpenGL-accelerate (3.1.0)
pyOpenSSL (0.15.1)
pyparsing (2.1.5)
pyparted (3.10.7)
pyPdf (1.13)
pypoppler (0.12.2)
pyserial (3.1.1)
PySocks (1.5.6)
python-augeas (0.5.0)
python-dateutil (2.4.2)
python-dmidecode (3.12.2)
python-ldap (2.4.17)
python-ly (0.9.4)
python-meh (0.43)
python-nss (0.16.0)
python-poppler-qt4 (0.18.1)
python-systemd (231)
pytz (2015.4)
pyudev (0.21.0)
pyusb (1.0.0)
pyxattr (0.5.3)
PyXB (1.2.4)
pyxdg (0.25)
PyYAML (3.11)
reportlab (3.3.0)
requests (2.10.0)
rope (0.10.2)
rpm-python (4.13.0rc1)
scdate (1.10.9)
scipy (0.14.1)
setuptools (18.0.1)
simplejson (3.5.3)
six (1.9.0)
slip (0.6.4)
slip.dbus (0.6.4)
Sphinx (1.2.3)
spyder (2.3.8)
SSSDConfig (1.14.1)
tepache (1.2)
uniconvertor (2.0)
Unidecode (0.4.16)
urlgrabber (3.10.1)
urllib3 (1.15.1)
vollib (0.1.5)
wxPython (3.0.2.0)
wxPython-common (3.0.2.0)
yum-langpacks (0.4.5)
yum-metadata-parser (1.1.4)

一切都在那里,vollib(0.1.5),let-be-rational(1.0.9),simplejson(3.5.3),numpy(1.9.2)和pandas(0.19.0)都在列表中。 。

我不明白vollib有什么问题。有人可以帮我安装此软件包吗?

菲利普·邹

首先,black_scholes它不包含在软件包__init__.py文件中,vollib因此您不能只是import vollib第二black_scholes个是不可调用的模块。正确用法:

import vollib.black_scholes
c = vollib.black_scholes.black_scholes('c',100,90,.5,.01,.2)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章