Skip to content Skip to sidebar Skip to footer

How To Use/install Python 2to3?

From this https://docs.python.org/3.4/library/2to3.html it says that 2to3 should be installed as a script alongside the python interpreter. However, in my /usr/bin/ folder there a

Solution 1:

You need to first install the following packages:

apt install 2to3
apt install python3-lib2to3
apt install python3-toolz

For windows just install 2to3

pip install 2to3

Then, You can simply go to that directory your python file is in and type the following command:

2to3 ./filename.py

OR for writing the updated python 3 code to the existing file

2to3 . -w

This last will convert all the python files that are in the directory.

Solution 2:

So the solution is that at least not for me, the Tools/scripts files were not automatically installed. On ubuntu this would be solved by installing python-examples which on opensuse is called python-demo

Solution 3:

On CentOS (and other RHEL-like distros) you will need to run yum install python-tools, which installs 2to3 to /usr/bin/2to3

Solution 4:

So far I've been using pip install 2to3. Conversions worked like absolute charm! (I'm on Ubuntu 18.04)

Solution 5:

On Fedora 29, the python-tools is not providing 2to3. I had to install the development package:

dnf install python3-devel

I found this out by first calling:

dnf whatprovides /usr/bin/2to3

Post a Comment for "How To Use/install Python 2to3?"