如何在anaconda3 python上运行anaconda2 python [英] How to run anaconda2 python on anaconda3 python

查看:93
本文介绍了如何在anaconda3 python上运行anaconda2 python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个静态python版本3.7和2.7第一个静态位置是:〜/anaconda3/bin/python第二个静态位置是:〜/anaconda2/bin/python

I have two static python versions 3.7 and 2.7 The 1st static locations is: ~/anaconda3/bin/python The 2nd static locations is: ~/anaconda2/bin/python

我想运行一个仅在python 3中的另一个脚本中使用python2的方法.

I want to run a method that only works with python2 inside of another script in python 3.

此外,我想从该python2脚本中获得一个返回值.

Also, I want to get a returned value from that python2 script.

什么是合适的解决方案?

What would be the appropriate solution?

谢谢

推荐答案

我认为适当的解决方案是仅使用一次conda安装.

I think the appropriate solution is to just use one installation of conda.

然后在该安装中,您可以为python 2创建一个环境,为python3创建另一个环境.

Then within that installation, you can create one environment for python 2 and another environment for python3.

conda create --name py2 python=2.7
conda create --name py3 python=3.5

来源: https://docs.anaconda.com/anaconda/user-guide/tasks/switch-environment/

之后,您可以使用py3环境运行python3部分,并使用py2环境运行python2部分.

After that, you can use the py3 environment to run the python3 part and the py2 environment to run python2 part.

您可能必须安装相同"的安装程序.打包到py2和py3环境.但这很好.例如,软件包X可能具有适用于python2的旧版本和适用于python3但不适用于python 2的新版本.在这种情况下,您将旧版本安装在py2上,将新版本安装在py 3上.

You might have to install the "same" package to both the py2 and the py3 environment. But that is fine. For example, package X might have an old version that works for python2 and a new version that works for python3 but not python 2. In this case, you install the old version on py2 and the new version on py 3

在python 2和python 3脚本之间传递值:使用python 2脚本将值保存到文件中.然后让python3脚本读取文件.

Passing value between the python 2 and python 3 scripts: save the value to a file with the python 2 script. Then let the python3 script read the file.

这篇关于如何在anaconda3 python上运行anaconda2 python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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