简体   繁体   English

Python 3to2工具-至少需要

[英]Python 3to2 Tool - Requires At Least

So, I'm using 3to2 to port my Python 3.3 code back to version 2.x. 因此,我正在使用3to2将我的Python 3.3代码移植回2.x版本。 I, believe, I correctly installed 3to2 by downloading the .tar.gz, cd to the file and running python3.3 setup.py build and then python3.3 setup.py install , so I don't think that is what is causing the issue. 我相信,我已通过下载.tar.gz, cd到文件并运行python3.3 setup.py build ,然后运行python3.3 setup.py install正确安装了3to2,所以我不认为这是什么原因问题。

The issue: the issue is that after I cd to the correct file, with the code I wish to use 3to2 on, I run 3to2 filename.py , which then returns the following: 问题是:问题是,我将cd编码到正确的文件后,并希望使用3to2的代码,然后运行3to2 filename.py ,然后返回以下内容:

 Checking Python version info...
 ERROR: 3to2 requires at least Python 2.7 in the 2.x branch.

Now, I have Python 3.3 installed, which I did myself and Python 2.7, which came pre-installed on my [Mac - OSX Lion 10.7.3] computer. 现在,我已经安装了Python 3.3(我自己做了)和Python 2.7(已预先安装在我的[Mac-OSX Lion 10.7.3]计算机上)。 Any ideas why this may be? 任何想法为什么会这样? Thanks! 谢谢!

Even though this question is pretty old, I figured I can still help if anyone else has this same issue. 即使这个问题已经很老了,我仍然认为如果有人遇到同样的问题,我仍然可以提供帮助。

  • If you've installed 3to2 already, uninstall it. 如果已经安装了3to2,请卸载它。 I used pip, so if you did too, run a pip uninstall 3to2 . 我使用了pip,所以如果您也这样做,请运行pip uninstall 3to2
  • If you're on OSX, do a quick python --version and make sure that your current version is 2.7.*. 如果您使用的是OSX,请执行快速python --version并确保当前版本为2.7。*。
  • To get a working version of 3to2 run 'sudo python -m pip install 3to2'. 要获得3to2的工作版本,请运行'sudo python -m pip install 3to2'。

Now, when you run 3to2, it will be referencing the correct python version. 现在,当您运行3to2时,它将引用正确的python版本。

I feel your pain I spent the last hour troubleshooting this issue on my mac, below is what I did... 我感到您很痛苦,我花了最后一个小时在Mac上对这个问题进行了故障排除,以下是我的工作...

Open terminal, type : 打开终端,输入:

brew install python

note : brew might mention that python is already installed, or that it's installed but unlinked... either way. 注意: brew可能会提到已经安装了python,或者已经安装但未链接python。 Then type : 然后输入:

brew link --overwrite python

echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile

If this doesn't work try typing brew doctor , I would have never been able to fix my problem without it's feedback.. 如果这样做不起作用,请尝试输入brew doctor ,如果没有反馈,我将永远无法解决我的问题。

This fixed my problem, but there might another way... 这解决了我的问题,但还有另一种方法...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM