如何在 Python 3 项目中使用 Python 2 包? [英] How to use Python 2 packages in Python 3 project?

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

问题描述

如何在python 3项目中使用python 2包?

How to use python 2 packages in python 3 project?

我有一个 Python 3 项目,但我需要一些用 Python 2 编写的包.

I have a Python 3 project, but I need some packages which are written in Python 2.

我不想重写这些 python-2 包,所以 fork/2to3 不是一个选项.

推荐答案

你不能.您在 py3 代码库中导入的任何模块都需要与 py3 兼容.如果你不能让上游项目为你做,你就必须自己做.正如评论中提到的,2to3 实用程序应该可以帮助您.

You can't. Any module you import in py3 codebase needs to be py3 compatible. If you can't make the upstream project do it for you, you'll have to do it yourself. As mentioned in the comments, 2to3 utility should help you with that.

这篇关于如何在 Python 3 项目中使用 Python 2 包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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