Skip to main content
Quote `2to3.py` script path to allow it working from `C:\Program Files\Python37` installation path
Source Link
ceztko
  • 15.4k
  • 5
  • 65
  • 86

You can set up 2to3.py to run as a command when you type 2to3 by creating a batch file in the same directory as your python.exe file (assuming that directory is already on your windows path - it doesn't have to be this directory it just is a convenient, relatively logical spot).

Lets assume you have python installed in C:\Python33. If you aren't sure where your python installation is, you can find out where Windows thinks it is by typing where python from the command line.

You should have python.exe in C:\Python33 and 2to3.py in C:\Python33\Tools\Scripts.

Create a batch file called 2to3.bat in C:\Python33\Scripts and put this line in the batch file

@python %~dp0\"%~dp0\..\Tools\Scripts\2to3.pypy" %* 

The %~dp0 is the location of the batch file, in this case c:\Python33\Scripts and the %* passes all arguments from the command line to the 2to3.py script. After you've saved the .bat file, you should be able to type 2to3 from the command line and see

At least one file or directory argument required. Use --help to show usage. 

I have found this technique useful when installing from setup.py, because sometimes the setup script expects 2to3 to be available as a command.

You can set up 2to3.py to run as a command when you type 2to3 by creating a batch file in the same directory as your python.exe file (assuming that directory is already on your windows path - it doesn't have to be this directory it just is a convenient, relatively logical spot).

Lets assume you have python installed in C:\Python33. If you aren't sure where your python installation is, you can find out where Windows thinks it is by typing where python from the command line.

You should have python.exe in C:\Python33 and 2to3.py in C:\Python33\Tools\Scripts.

Create a batch file called 2to3.bat in C:\Python33\Scripts and put this line in the batch file

@python %~dp0\..\Tools\Scripts\2to3.py %* 

The %~dp0 is the location of the batch file, in this case c:\Python33\Scripts and the %* passes all arguments from the command line to the 2to3.py script. After you've saved the .bat file, you should be able to type 2to3 from the command line and see

At least one file or directory argument required. Use --help to show usage. 

I have found this technique useful when installing from setup.py, because sometimes the setup script expects 2to3 to be available as a command.

You can set up 2to3.py to run as a command when you type 2to3 by creating a batch file in the same directory as your python.exe file (assuming that directory is already on your windows path - it doesn't have to be this directory it just is a convenient, relatively logical spot).

Lets assume you have python installed in C:\Python33. If you aren't sure where your python installation is, you can find out where Windows thinks it is by typing where python from the command line.

You should have python.exe in C:\Python33 and 2to3.py in C:\Python33\Tools\Scripts.

Create a batch file called 2to3.bat in C:\Python33\Scripts and put this line in the batch file

@python "%~dp0\..\Tools\Scripts\2to3.py" %* 

The %~dp0 is the location of the batch file, in this case c:\Python33\Scripts and the %* passes all arguments from the command line to the 2to3.py script. After you've saved the .bat file, you should be able to type 2to3 from the command line and see

At least one file or directory argument required. Use --help to show usage. 

I have found this technique useful when installing from setup.py, because sometimes the setup script expects 2to3 to be available as a command.

moved suggested batch file to user script dir, rather than root; suppressed cmd output from batch file
Source Link
monknomo
  • 550
  • 8
  • 26

You can set up 2to3.py to run as a command when you type 2to3 by creating a batch file in the same directory as your python.exe file (assuming that directory is already on your windows path - it doesn't have to be this directory it just is a convenient, relatively logical spot).

Lets assume you have python installed in C:\Python33. If you aren't sure where your python installation is, you can find out where Windows thinks it is by typing where python from the command line.

You should have python.exe in C:\Python33 and 2to3.py in C:\Python33\Tools\Scripts.

Create a batch file called 2to3.bat in C:\Python33\Python33\Scripts and put this line in the batch file

python@python %~dp0Tools\Scripts\2to3%~dp0\..\Tools\Scripts\2to3.py %* 

The %~dp0 is the location of the batch file, in this case c:\Python33\Python33\Scripts and the %* passes all arguments from the command line to the 2to3.py script. After you've saved the .bat file, you should be able to type 2to3 from the command line and see

At least one file or directory argument required. Use --help to show usage. 

I have found this technique useful when installing from setup.py, because sometimes the setup script expects 2to3 to be available as a command.

You can set up 2to3.py to run as a command when you type 2to3 by creating a batch file in the same directory as your python.exe file (assuming that directory is already on your windows path - it doesn't have to be this directory it just is a convenient, relatively logical spot).

Lets assume you have python installed in C:\Python33. If you aren't sure where your python installation is, you can find out where Windows thinks it is by typing where python from the command line.

You should have python.exe in C:\Python33 and 2to3.py in C:\Python33\Tools\Scripts.

Create a batch file called 2to3.bat in C:\Python33 and put this line in the batch file

python %~dp0Tools\Scripts\2to3.py %* 

The %~dp0 is the location of the batch file, in this case c:\Python33 and the %* passes all arguments from the command line to the 2to3.py script. After you've saved the .bat file, you should be able to type 2to3 from the command line and see

At least one file or directory argument required. Use --help to show usage. 

I have found this technique useful when installing from setup.py, because sometimes the setup script expects 2to3 to be available as a command.

You can set up 2to3.py to run as a command when you type 2to3 by creating a batch file in the same directory as your python.exe file (assuming that directory is already on your windows path - it doesn't have to be this directory it just is a convenient, relatively logical spot).

Lets assume you have python installed in C:\Python33. If you aren't sure where your python installation is, you can find out where Windows thinks it is by typing where python from the command line.

You should have python.exe in C:\Python33 and 2to3.py in C:\Python33\Tools\Scripts.

Create a batch file called 2to3.bat in C:\Python33\Scripts and put this line in the batch file

@python %~dp0\..\Tools\Scripts\2to3.py %* 

The %~dp0 is the location of the batch file, in this case c:\Python33\Scripts and the %* passes all arguments from the command line to the 2to3.py script. After you've saved the .bat file, you should be able to type 2to3 from the command line and see

At least one file or directory argument required. Use --help to show usage. 

I have found this technique useful when installing from setup.py, because sometimes the setup script expects 2to3 to be available as a command.

was more explicit about where python.exe is to be found
Source Link
monknomo
  • 550
  • 8
  • 26

You can set up 2to3.py to run as a command when you type 2to3 by creating a batch file in the same directory as your python.exe file (assuming that directory is already on your windows path - it doesn't have to be this directory it just is a convenient, relatively logical spot).

Lets assume you have python installed in C:\Python33. If you aren't sure where your python installation is, you can find out where Windows thinks it is by typing where python from the command line.

You should have python.exe in that directoryC:\Python33 and 2to3.py in C:\Python33\Tools\Scripts.

Create a batch file called 2to3.bat in C:\Python33 and put this line in the batch file

python %~dp0Tools\Scripts\2to3.py %* 

The %~dp0 is the location of the batch file, in this case c:\Python33 and the %* passes all arguments from the command line to the 2to3.py script. After you've saved the .bat file, you should be able to type 2to3 from the command line and see

At least one file or directory argument required. Use --help to show usage. 

I have found this technique useful when installing from setup.py, because sometimes the setup script expects 2to3 to be available as a command.

You can set up 2to3.py to run as a command when you type 2to3 by creating a batch file in the same directory as your python.exe file (assuming that directory is already on your windows path - it doesn't have to be this directory it just is a convenient, relatively logical spot).

Lets assume you have python installed in C:\Python33. If you aren't sure where your python installation is, you can find out where Windows thinks it is by typing where python from the command line.

You should have python.exe in that directory and 2to3.py in C:\Python33\Tools\Scripts.

Create a batch file called 2to3.bat in C:\Python33 and put this line in the batch file

python %~dp0Tools\Scripts\2to3.py %* 

The %~dp0 is the location of the batch file, in this case c:\Python33 and the %* passes all arguments from the command line to the 2to3.py script. After you've saved the .bat file, you should be able to type 2to3 from the command line and see

At least one file or directory argument required. Use --help to show usage. 

I have found this technique useful when installing from setup.py, because sometimes the setup script expects 2to3 to be available as a command.

You can set up 2to3.py to run as a command when you type 2to3 by creating a batch file in the same directory as your python.exe file (assuming that directory is already on your windows path - it doesn't have to be this directory it just is a convenient, relatively logical spot).

Lets assume you have python installed in C:\Python33. If you aren't sure where your python installation is, you can find out where Windows thinks it is by typing where python from the command line.

You should have python.exe in C:\Python33 and 2to3.py in C:\Python33\Tools\Scripts.

Create a batch file called 2to3.bat in C:\Python33 and put this line in the batch file

python %~dp0Tools\Scripts\2to3.py %* 

The %~dp0 is the location of the batch file, in this case c:\Python33 and the %* passes all arguments from the command line to the 2to3.py script. After you've saved the .bat file, you should be able to type 2to3 from the command line and see

At least one file or directory argument required. Use --help to show usage. 

I have found this technique useful when installing from setup.py, because sometimes the setup script expects 2to3 to be available as a command.

Source Link
monknomo
  • 550
  • 8
  • 26
Loading