Python- 如何在 jupyter notebook 中安装 pyvttbl

Python- how to install pyvttbl in jupyter notebook

我尝试使用 !pip install 安装它

!pip install pyvttbl

它给了我这条消息

Requirement already satisfied: pyvttbl 
Requirement already satisfied: dictset
Requirement already satisfied: pystaggrelite3

但是,当我将其导入为

import pyvttbl as pt

它给了我

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-7-89ef5f67d382> in <module>()
----> 1 import pyvttbl as pt

D:\Anaconda3\lib\site-packages\pyvttbl\__init__.py in <module>()
      8 # This software is funded in part by NIH Grant P20 RR016454.
      9 
---> 10 from base import PyvtTbl, DataFrame
     11 
     12 from misc import *

ModuleNotFoundError: No module named 'base'

当我尝试将 base 安装为

!pip install base

它给了我这个

    Collecting base
Using cached base-1.0.4.tar.gz
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "C:\Users\User\AppData\Local\Temp\pip-build-u1xkw0lp\base\setup.py", line 40, in <module>
            LONG_DESCRIPTION = read("README.rst")
          File "C:\Users\User\AppData\Local\Temp\pip-build-u1xkw0lp\base\setup.py", line 21, in read
            return codecs.open(os.path.join(os.path.dirname(__file__), fname)).read()
          File "D:\Anaconda3\lib\encodings\cp1252.py", line 23, in decode
            return codecs.charmap_decode(input,self.errors,decoding_table)[0]
        UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 5: character maps to <undefined>

谁能帮我理解这个问题?

背景

Pyvttbl 不再主动维护,这就是您遇到一些困难的原因。

我假设您正在使用 python 3.x,在我看来 pyvttbl 现在只适用于 python 2.7。

解决方案

注意:仅适用于系统 运行通过 Anaconda 使用 jupyter notebook。

我设法让它在我的 python 2.7 环境中工作。但是我无法在新环境中重现有效安装。所以我将我的 py27 env 导出为一个 .yml 文件,你可以通过这些步骤克隆它;

1) 从 this gist

下载并解压 .yml env

2) cd 到解压缩的 .yml 文件的位置。

3) 使用以下命令创建我的 py27 环境的克隆;

conda env create -f py27.yml

4) conda 完成安装后激活环境;

activate py27

5) 然后将这个 env 添加到您的 jupyter notebook 内核列表中;

ipython kernel install --name py27

现在,当您启动 jupyter notebook 时,您可以选择在单击新建按钮时创建一个 py27 notebook。之后你应该可以 运行 pyttbl.

如果您仍有问题,请在下方评论。