博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nonetype_解决Pyvttbl Float和NoneType错误的分步指南
阅读量:2518 次
发布时间:2019-05-11

本文共 6288 字,大约阅读时间需要 20 分钟。

nonetype

In this short post I will show you a quick fix for the error “unsupported operand type(s) for +: ‘float’ and ‘NoneType’” with Pyvttbl. In earlier posts I have showed how to carry out ANOVA using Pyvttbl (among other packages. See posts , , , and for ANOVA using pyvttbl). However,  Pyvttbl is not compatible with Python versions greater 1.11 (e.g., 1.12.0, that I am running). This may, of course, be due to that Pyvttbl have not been updated in quite some time. My solution to this problem involves setting up a Python virtual environment (the set up of the virtual environment it is based on the ). You will learn how to set up the virtual environment in and .

在这篇简短的文章中,我将向您展示Pyvttbl错误“ +不支持的操作数类型:'float'和'NoneType'”的快速修复。 在早期的帖子中,我已经展示了如何使用Pyvttbl进行方差分析(其它包间。见帖子 , , ,以及对ANOVA使用pyvttbl)。 但是,Pyvttbl与大于1.11的Python版本(例如,我正在运行的1.12.0)不兼容。 当然,这可能是由于Pyvttbl在相当长的时间内没有更新。 我对这个问题的解决方案涉及建立一个Python虚拟环境(该虚拟环境的建立是基于《 )。 您将学习如何在和设置虚拟环境。

Linux设置 (Linux set-up)

First, we will need to install the package :

首先,我们需要安装软件包 :

pip install virtualenv

Next we continue with opening up a terminal window. Here, we change directory to the where we typically have our Python projects and create a directory for our new Pyvttbl environment:

接下来,我们继续打开终端窗口。 在这里,我们将目录更改为我们通常拥有Python项目的位置,并为新的Pyvttbl环境创建目录:

The next step is to activate the virtual environment:

下一步是激活虚拟环境:

source pyvttbl_env/bin/activate

Now we should have a virtual environment set up and we can start installing numpy 1.1.0 and pyvttbl:

现在我们应该建立一个虚拟环境,我们可以开始安装numpy 1.1.0和pyvttbl:

pip install numpy==1.11.0 pyvttbl

In the code snippet above, it is important that you set the version of Numpy (e.g., 1.11.0) that we want to install. Thus, we get the version that have been previously working with Pyvttbl.

在上面的代码段中,重要的是设置我们要安装的Numpy的版本(例如1.11.0)。 因此,我们获得了以前与Pyvttbl一起使用的版本。

Remember, if we want to use any other Python packages (e.g., jupyter notebooks, Seaborn, matplotlib) we need to install them in our virtual environment. We can, of course, just add any package to the pip install snippet above:

请记住 ,如果我们要使用其他任何Python软件包(例如jupyter笔记本,Seaborn,matplotlib),则需要将其安装在虚拟环境中。 当然,我们可以将任何包添加到上面的pip install片段中:

pip install numpy==1.11.0 pyvttbl jupyter matplotlib seaborn

Now, lets check the version of Numpy using ipython:

现在,让我们使用ipython检查Numpy的版本:

Finally, if we want to do our ANOVA in a jupyter notebook we need to install a new kernel that uses the one in the virtual environment. If we don’t do this we will run the notebook from the global environment and, thus, we will import whatever version of Numpy we have installed on the system:

最后,如果我们想在jupyter笔记本中进行ANOVA,则需要安装一个在虚拟环境中使用该内核的新内核。 如果不这样做,我们将从全局环境中运行笔记本,因此,将导入系统上安装的任何版本的Numpy:

ipython kernel install --name "pyvttbl_env" --user

If we follow the image above, we also start up a Jupyter notebook. When creating a new notebook to run our python ANOVAs using pyvttbl in we need to select our new core (i.e., pyvttbl_env”).  In the (after Windows set-up) you can see that we don’t get the error “unsupported operand type(s) for +: ‘float’ and ‘NoneType’”. Note, we do get a warning that in the future what pvttbl is trying to do is not going to work.

如果我们遵循上面的图片,我们还将启动Jupyter笔记本。 当创建一个新的笔记本来使用pyvttbl运行我们的python ANOVA时,我们需要选择我们的新内核(即pyvttbl_env”)。 在的 (在Windows设置之后),您可以看到我们没有收到错误“ +不支持的操作数类型:'float'和'NoneType'”。 请注意,我们确实收到警告,将来pvttbl尝试执行的操作将无法正常工作。

Windows设置 (Windows set-up)

For Windows, the set-up is basically the same. First, we will need to install virtualenv:

对于Windows,设置基本相同。 首先,我们需要安装virtualenv:

pip install virtualenv

Next step for Windows user is, of course, similar but we need to start the Command Prompt (here is how). Lets change the directory to where our Python project are intended to be stored and create the new Pyvttbl environment. First, we create a directory and then we create the virtual environment in this directory:

Windows用户的下一步当然是相似的,但是我们需要启动命令提示符(这里是方法)。 让我们将目录更改为要存储我们的Python项目的目录,并创建新的Pyvttbl环境。 首先,我们创建一个目录,然后在该目录中创建虚拟环境:

We continue by activating our virtual environment for running Numpy 1.11.0 and Pyvttbl:

我们继续激活用于运行Numpy 1.11.0和Pyvttbl的虚拟环境:

Next step is to activate our virtual environment. Here, it is a bit different for Windows users compared to Linux users:

下一步是激活我们的虚拟环境。 在这里,与Linux用户相比,Windows用户有所不同:

source pyvttbl_env/Scripts/activate

Now that we have a virtual environment set up we can install an older version of Numpy. Here we will also depart on how this is done in Linux.  I had a bit of a problem with installing Scipy (Pyvttbl depends on Scipy, for instance) using Pip.

现在我们已经建立了虚拟环境,我们可以安装较旧版本的Numpy。 在这里,我们还将介绍如何在Linux中完成此操作。 使用Pip安装Scipy(例如,Pyvttbl取决于Scipy)时,我遇到了一些问题。

Fortunately, there are Windows binaries for both and . Download the version you need and put it in the directory for the virtual environment and use pip to install:

幸运的是, 和都有Windows二进制文件。 下载所需的版本并将其放在虚拟环境的目录中,然后使用pip进行安装:

pip install numpy-1.11.3+mkl-cp27-cp27m-win32.whl scipy-0-19.1-cp27-cp27m-win32.whl

Any additional packages that we may need in our data analysis will, of course, also have to be installed in the virtual environment. Luckily us, we can just use pip again (no external downloading, that is!):

当然,我们在数据分析中可能需要的任何其他软件包也必须安装在虚拟环境中。 幸运的是,我们可以再次使用pip(即无需外部下载!):

pip install jupyter matplotlib seaborn

Since we plan to run our ANOVA in a notebook we have one final step that need to be done. To get Jupyter to run WITHIN the virtual environment (or else it will use whatever Numpy version we had problems with earlier). Thus, we need to install a new kernel for the virtual environment. This is easy done using the command prompt, again:

由于我们计划在笔记本中运行方差分析,因此我们需要完成最后一步。 为了让Jupyter在虚拟环境中运行(否则它将使用我们之前遇到问题的任何Numpy版本)。 因此,我们需要为虚拟环境安装一个新内核。 再次使用命令提示符很容易做到这一点:

ipython kernel install --name "pyvttbl_env" --user

Jupyter笔记本 (Jupyter notebook)

In this notebook, we can run our ANOVA using pyvttbl without the “unsupported operand type(s) for +: ‘float’ and ‘NoneType’ error! Note, Windows user will have a different Numpy versions (we installed 1.11.3) and if you run Linux you can of course install this version to. Of course, we do get the warning (the future is now!)

在此笔记本中,我们可以使用pyvttbl运行ANOVA,而不会出现+的“不受支持的操作数类型:'float'和'NoneType'错误! 请注意,Windows用户将具有不同的Numpy版本(我们安装了1.11.3),如果您运行Linux,则当然可以安装该版本。 当然,我们确实会收到警告(未来就在眼前!)

翻译自:

nonetype

转载地址:http://wkhwd.baihongyu.com/

你可能感兴趣的文章
Android Studio-—使用OpenCV的配置方法和demo以及开发过程中遇到的问题解决
查看>>
第2天线性表链式存储
查看>>
python自动化测试-D11-学习笔记之一(yaml文件,ddt)
查看>>
mysql存储过程使用游标循环插入数据
查看>>
Ubuntu 12.04 添加新用户并启用root登录
查看>>
初涉MySQL
查看>>
NSMutableURLRequest和NSURLConnection用Post方式上传照
查看>>
mean shift博客推荐
查看>>
App Naver Line 5.3 add new features - "True Delete"
查看>>
shell中$0,$?,$!等的特殊用法
查看>>
jsp的page指令的错误页面跳转
查看>>
android用户界面之GridView教程实例汇总
查看>>
夺命雷公狗----Git---7---GitHub当仓库本地使用(完)
查看>>
.NET/ASP.NET Routing路由(深入解析路由系统架构原理)http://wangqingpei557.blog.51cto.com/1009349/1312422...
查看>>
647. Palindromic Substrings 互文的子字符串
查看>>
[poj2096]Collecting Bugs[概率dp]
查看>>
Mongodb数据导出工具mongoexport和导入工具mongoimport介绍(转)
查看>>
图片和视频操作核心代码
查看>>
css实现简单几何图形
查看>>
asp.net 2.0中实现异步处理任务.
查看>>