在同一个项目中使用多个 Python 解释器? [英] Multiple Python Interpreters used in the same project?

查看:67
本文介绍了在同一个项目中使用多个 Python 解释器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 pycharm,它只允许您使用一个解释器,例如 Python 2.7.5 或 Python 3.5.1.

I am using pycharm and it only lets you use one interpreter for example Python 2.7.5 or Python 3.5.1.

问题是我有一些模块,一个来自谷歌,用于访问分析数据,另一个叫 docxfactory,我想一起使用.

The problem is I have certain modules one from google to access analytics data and one called docxfactory that I want to use together.

我只能让 docxfactory 在 Python 3.5.1 上工作,而我只能让分析在 2.7.5 上工作...

I can only get docxfactory to work on Python 3.5.1 and I can only get analytics to work on 2.7.5...

我怎样才能得到它以便我可以一起使用这两个模块?我在这里读到一个答案,说将它们放在两个不同的项目中,除非我做错了,否则我尝试过但没有成功......有任何想法吗?

How can I get it so I can use these two modules together? I read an answer on here that said to have them in two different projects and unless I did that wrong I tried that with no success... any ideas?

推荐答案

一个想法是编写两个单独的脚本;一种用于分析,一种用于 docxfactory.决定哪个是驱动程序,另一个是驱动程序外壳——确保调用适当版本的 python.

One idea is to write two seperate scripts; one for analytics and one for docxfactory. Decide which of these is the driver, and have that driver shell the other -- being sure to invoke the appropriate version of python.

例如:

#/usr/bin/env python2.7
import subprocess
# Do something with analytics
# ...
# Now call docxfactory script
subprocess.call(['python3', 'docxcript.py'])

这篇关于在同一个项目中使用多个 Python 解释器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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