Python Anaconda:如何测试更新的库是否与我现有的代码兼容? [英] Python Anaconda: how to test if updated libraries are compatible with my existing code?

查看:184
本文介绍了Python Anaconda:如何测试更新的库是否与我现有的代码兼容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows 7计算机上使用Python 2.7 Anaconda安装进行数据分析和科学计算.

I am using a Python 2.7 Anaconda installation on a Windows 7 machine for data analysis and scientific computing.

发布新库(例如,pandas,patsy等的新版本)时,您如何建议我测试新版本与现有代码的兼容性?同一台机器上可以同时安装两个Anaconda吗?您会推荐某种虚拟环境吗?使用Anaconda可以轻松地回滚到以前版本的库吗?

When new libraries are released (e.g. a new version of pandas, patsy, etc), how would you recommend I test the compatibility of the new version with my existing code? Is it possible to have two Anaconda installations on the same machine? Would you recommend some kind of virtual environment? Is there an easy way to roll back to previous versions of a library with Anaconda?

我问,因为过去一周的大部分时间试图弄清楚为什么我以前的代码不再适用于新版本的pandas和patsy.因此,无需评论我有多生气...

I ask because have spent the best part of the last week trying to figure out why my previous code no longer works with the new versions of pandas and patsy. No need to comment how mad I am because of this...

顺便说一句,这也表明Py​​thon对于数据分析和科学计算来说是一种潜在的有趣语言,但仅仅是潜在的.主要库太不稳定且不成熟. Pandas大约在3 1/2年前发布,距离v 1.0尚很遥远,所以我不希望随着时间的推移会变得更好.想象一下,如果每个新版本的Matlab都需要对所有代码进行重大重写:Mathworks早就倒闭了!

Incidentally, this also goes to show that Python is a potentially interesting language for data analysis and scientific computing, but only potentially. The main libraries are too unstable and immature. Pandas was released about 3 1/2 years ago and we're still very far from a v 1.0, so I'm not hopeful that things will get better with time. Imagine if every new release of Matlab required a major rewrite of all your code: Mathworks would have gone out of business long ago!

推荐答案

您可以将所有依赖项的特定版本安装在单独的虚拟环境中,并在此处测试模块.这可以通过以下工作流程来实现,

You could install the specific versions of all the dependencies in a separate virtual environment and test you module there. This can be achieved with the following work-flow,

$ conda create --yes -n new_env pip numpy=1.9 pandas=0.16 python=2 # specify the required versions
$ activate new_env
$ # install and test your module
$ deactivate

您可以在计算机上拥有任意数量的虚拟环境.

You can have as many virtual environment as you want on a machine.

当更新中断时,我可以理解沮丧,但是恕我直言,python中的核心科学模块(numpy,scipy和pandas到达那里)相当稳定和成熟.稳定性与版本1.0无关.的确,可能存在一些向后不兼容的更改,因为要进行改进并保持可管理的代码库是必须付出的代价,但是总体而言,这是相当合理的.

I can understand the frustration when things break on an update, but IMHO the core scientific modules in python (numpy, scipy, and pandas getting there) are pretty stable and mature. Stability is not about having a version 1.0. True, there can be some backward incompatible changes, because it's the price to pay to have improvements and keep a manageable code base, but overall things are rather reasonable.

更多的是有关部署/测试策略的信息,不应将其与给定计算机上的安装捆绑在一起.如果您将版本控制与持续集成(CI)结合使用并在虚拟环境中进行部署,则如果更新中断,应该很容易恢复到以前的设置.

It's more about the deployment/testing strategy that shouldn't be tied to an install on a given machine. If you use version control with continuous integration (CI) and deploying in a virtual environment, it should be pretty easy to revert to the previous setup if something breaks on an update.

这篇关于Python Anaconda:如何测试更新的库是否与我现有的代码兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆