;C:\python27 to the Path variable.I want to alias
topython3on Windows.python
You haven't mentioned what release of Python you are using (e.g. "vanilla" Python, Anaconda, SciPy, etc.), but if I am not misunderstanding, this likely shouldn't be necessary. For Windows versions of Python (i.e. not WSL), is not typically a standard alias. That is, the Python 3.x executable is usually just python3 (python).python.exe
Be aware that should be in a folder listed in your Windows Path if you want to access it as just python.exe. You can find a refresher on editing Windows Path variables here.python
If you meant the reverse (i.e. you want to run Python 3.x with ), then there are at least a few possible approaches (each item below is a separate option):python3
Make symbolic link called to your preferred copy of Python 3.x with mklink:python3.exe
mklink "C:\path\to\symlink\python3.exe" "C:\path\to\Python3\python.exe"
Copy the file in your preferred installation of Python 3.x and rename the copied executable python.exe.python3.exe
If you aren't set on specifically using and have the Python Launcher for Windows (python3) installed which comes with "vanilla" Python from python.org, you can use:py.exe
# Use the "default" installation of Python 3.x,
# as detected by the Python Launcher for Windows.
py 3
or:
# Use a specific version of Python 3.x if you have more
# than one version installed, outside of a virtual environment.
py 3.8
Create a Windows batch file called with the following information:python3.bat
ex. python3.bat
C:\path\to\Python3\python.exe %*
You can also alias Python Launcher for Windows () calls in a similar manner in py.exe e.g.:python3.bat
ex. python3.bat
py 3 %*
or:
ex. python3.bat
py 3.8 %*
With all the options above, any "python3" file you wish to access from the command line (i.e. any symbolic link, a renamed executable copy, or py.exe) must be in a folder located in your Windows Path.python3.bat
Notes
These options obviously do not include any option to "alias" at the command line (e.g. via doskey macros, as mentioned in the comments, or possibly via actual alias commands specific to a given terminal). It also ignores the possibility that some distributions of Python could (theoretically) already come with a python.exe alias.python3
Creating a symbolic link with on Windows may require administrative privileges on versions of Windows earlier than some early releases of Windows 10.mklink
When creating a symbolic link, be certain to include the file extension (). This is not optional if you want the link to work correctly..exe
It is likely best to leave any renamed executable copy (option 2) in the same folder as the original .python.exe
Simply add this path to your PYTHONPATH environment variable. To do this, go to Control Panel / System / Advanced / Environment variable, and in the "User variables" sections, check if you already have PYTHONPATH. If yes, select it and click "Edit", if not, click "New" to add it.
Paths in PYTHONPATH should be separated with ";".
For some reason by typing only the "py" file name in the command prompt it worked for me. So I typed myScript.py and it ran correctly. Before this I typed "python myScript.py" and it produced the same error that you experienced. I have the environment variables set and PYTHONPATH=c:\python27. I hope this helps.PYTHONHOME=c:\python27