Mailing List Archive

Ole version set as default
Dear sir,
I am Pranav Bhardwaj and I stuck in a problem. My problem is
that in my system I have python 3.11.2 but when I type python in my command
prompt, my command prompt show that python version 2.7.13 as a default. And
I can't be able to find python 2.7.13 in my system in any file and I tried
various methods to set python 3.11.2 as a default but can't be able to do
so. I tried to change environment variables, try to find and delete python
2.7.13 , try to set python 3.11.2 as default, but I can't be able to do so.
So can you help me how can I solve this problem?
--
https://mail.python.org/mailman/listinfo/python-list
Re: Ole version set as default [ In reply to ]
On 3/29/2023 12:46 PM, Pranav Bhardwaj wrote:
> Dear sir,
> I am Pranav Bhardwaj and I stuck in a problem. My problem is
> that in my system I have python 3.11.2 but when I type python in my command
> prompt, my command prompt show that python version 2.7.13 as a default. And
> I can't be able to find python 2.7.13 in my system in any file and I tried
> various methods to set python 3.11.2 as a default but can't be able to do
> so. I tried to change environment variables, try to find and delete python
> 2.7.13 , try to set python 3.11.2 as default, but I can't be able to do so.
> So can you help me how can I solve this problem?

If you installed Python3 from python.org, then type "py". This will run
the latest version installed on your machine. "py" will give you the
option of running the latest version or earlier versions by specifying
them on the command line: "py -2" will give you Python 2+, "py -3.9"
will run Python 3.9 if it is installed, and so on.

This will run Python3.11, but you may still get the wrong version when
you try to run a Python-installed script from the command line. For
example, if you type "pip" to install packages that can be installed
from PyPi by the Pip command, the pip program for Python 2 may run instead.

Some of these programs, like pip, are Python modules and can be run
using the "-m" option:

py -m pip

This will run the right version of pip for whatever version of Python it
launches. I always run pip this way, and you should too. Many or most of
the Python scripts that were installed into the Python Scripts directory
can be run this way too.

That leaves other cases where a script might get launched from Python2's
Scripts directory because it is on your PATH. The way to make Python3's
directories get used instead of Python2's is to put them first on the
PATH, so that they will get checked first for the target file. It would
be too long to go into the details for changing the PATH here. If you
still have trouble after doing what I said above, feel free to come back
and ask how to do it. You can find out how to change the PATH on the
internet, so you probably won't need to come back here.

One final possibility for getting the wrong version of Python is if you
try to run a file whose name ends with ".py" without typing "py" before
it. In other words, on the command line you should type "py program.py",
not just "program.py". The installer for Python 3.11 should have taken
care of these file associations (as they are called in Windows) so it
will probably not be a problem. If it is, just make sure to include the
"py" when you run a Python program.

--
https://mail.python.org/mailman/listinfo/python-list
Re: Ole version set as default [ In reply to ]
On 3/29/23, Pranav Bhardwaj <pranavbhardwaj773@gmail.com> wrote:
> I am Pranav Bhardwaj and I stuck in a problem. My problem is
> that in my system I have python 3.11.2 but when I type python in my command
> prompt, my command prompt show that python version 2.7.13 as a default.

Run the following command in the shell

where.exe python

Note the first directory where "python" is found. Edit both the system
and the user environment variables to remove that directory from both
the system and user "Path" environment variable. Open a new shell from
Explorer, and confirm that "python" no longer runs Python 2. If
"python" still runs Python 2, repeat this procedure.

Next run the Python 3.11 installer again to modify the installation.
On the second page, enable the option to add Python to the environment
variables, and click "install". After it's done, open a new shell.
Running "python" should start Python 3.11. Also "pip" should work. You
should also be able to run Python using the "py" launcher and pip via
"py -m pip".

To ensure that that .py file association is correct, open the system
settings app and navigate to "Apps" -> "Default Apps". Enter ".py"
and ensure that it's associated with the Python app that has a rocket
on its icon (i.e. Python's "py" launcher). Repeat this for ".pyw",
".pyz", and ".pyc".
--
https://mail.python.org/mailman/listinfo/python-list
Re: Ole version set as default [ In reply to ]
On 3/29/23 10:46, Pranav Bhardwaj wrote:
> Dear sir,
> I am Pranav Bhardwaj and I stuck in a problem. My problem is
> that in my system I have python 3.11.2 but when I type python in my command
> prompt, my command prompt show that python version 2.7.13 as a default. And
> I can't be able to find python 2.7.13 in my system in any file

once you open that Olde Python that you can't find:

>>> import sys
>>> sys.executable

voila! you've found it.

and I tried
> various methods to set python 3.11.2 as a default but can't be able to do
> so. I tried to change environment variables, try to find and delete python
> 2.7.13 , try to set python 3.11.2 as default, but I can't be able to do so.
> So can you help me how can I solve this problem?

As noted elsewhere, for the python.org version, the Python Launcher
exists for this purpose.

py --list

shows you which Pythons it knows about, and with a '*' which one is the
default. You can instruct py which one should be default (for that you
need to create an ini file), but it will otherwise choose the latest, so
you shouldn't have the problem of it choosing 2.7 over 3.11 with the
launcher.


--
https://mail.python.org/mailman/listinfo/python-list
Re: Ole version set as default [ In reply to ]
Am 29.03.2023 um 18:46 schrieb Pranav Bhardwaj:
> Dear sir,
> I am Pranav Bhardwaj and I stuck in a problem. My problem is
> that in my system I have python 3.11.2 but when I type python in my command
> prompt, my command prompt show that python version 2.7.13 as a default. And
> I can't be able to find python 2.7.13 in my system in any file and I tried
> various methods to set python 3.11.2 as a default but can't be able to do
> so. I tried to change environment variables, try to find and delete python
> 2.7.13 , try to set python 3.11.2 as default, but I can't be able to do so.
> So can you help me how can I solve this problem?

Which OS is this? And what happens if you enter "python3" in your
command prompt?

HTH
Sibylle

--
https://mail.python.org/mailman/listinfo/python-list