pip安装后的vollib问题

时间:2016-11-05 23:06:42

标签: python pip

我已按如下方式安装了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和其他属性(例如helper,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: support@quantycarlo.com
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的问题是什么。 有人可以帮我安装这个软件包吗?

1 个答案:

答案 0 :(得分:2)

首先,import vollib未包含black_scholes,因此您不能只import vollib.black_scholes c = vollib.black_scholes.black_scholes('c',100,90,.5,.01,.2) 。第二个public class ScoreEntry extends AppCompatActivity implements View.OnClickListener { private EditText editText; private Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_score_entry); editText = (EditText) findViewById(R.id.editText); button = (Button) findViewById(R.id.button); button.setOnClickListener(this); } @Override public void onClick(View view) { if (view.getId() == R.id.button) { String value = editText.getText().toString(); // use the value here Log.d(ScoreEntry.class.getCanonicalName(), "The value is: " + value); } } } 是一个不可调用的模块。正确用法:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/activity_score_entry"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <EditText
        android:id="@+id/editText"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <Button
        android:id="@+id/button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</LinearLayout>