my problem is before I installed Anaconda, my python with python and py commands shows the same versions. After I installed Anaconda, my python version is using Anaconda installation. How to prevent this, because I don't want to use Anaconda python version on my Windows.
I already put my python PATH on the top
When I check the PATH, there's no anaconda PATH anywhere when I done my installation
My python version will use the default python version, not the Anaconda's version
You need to change the default opener for the .py files on your computer.
try to right-click on the .py file, select "open with" and look for python.
You can always use cmd and run the following:
python <path_to_file>
or
python3 <path_to_file>
It depended on your python version
(as long as you set your python path in windows Path)
Related
I installed official Python then Anaconda3 afterwards (both 3.9)
I suspect it is because I ticked 'Register Anaconda3 as my default Python 3.9' when I was installing Anaconda, that now when I type py -0p in cmd, the path goes to Anaconda (I do not have Anaconda in PATH). I would like Python 3.9 to use the official installation.
Installed Pythons found by py Launcher for Windows *
-3.9-64 C:\Users\xxx\anaconda3\python.exe
What exactly did ticking 'Register Anaconda3 as my default Python 3.9' change in my system? I would like to revert it. I already looked for py.ini and it does not exist beside py.exe and %LOCALAPPDATA%, so it is not that.
With reference to this comment: py launcher does not find my Python 2.7, I deleted \HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.9 in regedit. py -0p gave this output after a reboot, which is what I wanted:
Installed Pythons found by py Launcher for Windows *
-3.9-64 C:\Program Files\Python39\python.exe
My Python installation is system-wide, so the keys for the offical installation exist at \HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.9.
For those who installed Python for their user only, you may want to modify the keys in \HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.9 instead of deleting them.
Common issue here: I installed Python and then Spyder, and now when I install packages with "pip install ", Spyder can't find the modules, but if I call Python on the command prompt (using Windows), it finds all installed packages with pip.
I noticed that in Spyder, a new console shows it is running Python 3.7.9, but if I run "python -V" on the command promp, it shows Python 3.9.1 , also for "py -0" and "py -0p" it only shows one installation of Python, namely
>>> py -0p
Installed Pythons found by py Launcher for Windows
-3.9-64 C:\Users\my_name\AppData\Local\Programs\Python\Python39\python.exe *
so what is going on here? Why does Spyder seem to have its own Python version? Is this the reason why packages installed with pip are not communicating with Spyder?
I was facing the same issue as you. I understand your question and the answer to it is yes. However you can change it and use the systems python as well.
Tools -> preferences -> python interpreter -> select "use the following interpreter" and provide is the path to the directory that you have the systems python installed.
Restart spyder and the kernel should then show you the update version
For any library that you want to add that is not included in the default search path of spyder, you need add its path via the PYTHONPATH manager.
Go to Spyder->Tool-> PYTHONPATH manager ->Add Path
I installed Python 2.7 a long time ago on my PC (I am running Windows 10). Today I decided to install Python 3.7, but after typing 'python' into the command prompt the console printed 'python 2.7...'
I have no idea as to what I should do. Would this be a problem with my path configuration? I considered uninstalling python 2.7 but I still want it installed on my computer.
Configure multiple Python versions on Windows
Python 3.3 introduced the Python Launcher for Windows. Rather than using python.exe, call py and select the version with flags:
py -2.7
py -3
System-wide installations of Python 3.3 and later will put the launcher on your PATH.
Note on Virtual Environments (new in Python 3.5)
If the launcher is run with no explicit Python version specification, and a virtual environment (created with the standard library venv module or the external virtualenv tool) active, the launcher will run the virtual environment’s interpreter rather than the global one. To run the global interpreter, either deactivate the virtual environment, or explicitly specify the global Python version.
Outdated Method (not recommended)
Rename executables - After installing multiple versions, change the names of the executables. For example, for Python 2.7, under the installation folder, rename python.exe to python27.exe and rename Python 3.7 from python.exe to python37.exe. Then on the command line, select the version by entering python27 or python37. Whichever version is preferred, could be left as just python.
Add Path Environment Variables - For example, on Windows 10, go to the Windows menu and search for "environment variables" and click edit the system environment variables. In the System Properties dialog, click Environment Variables.... Under "System variables", select "Path". Click Edit.... Click New and add the first entry below. Click New again for each Path variable entry.
C:\Python27
C:\Python27\Scripts
C:\Python37
C:\Python37\Scripts
This will enable Python and pip. Be sure that paths match your actual installation directories.
I would suggest using pyenv
I have been using it and is working well for me. Some of the handy features of pyenv are
It allows installing multiple version on python easily
It allows switching python version with one command in global, shell or folder level
It also allows creating virtual env using virtualevn extension
I would suggest to use virtual environment. Soon or later you would you might get dependency problems.
You Can Configure The Python2 & python3 In Windows PC Like This:
First Of All Install Python 2 & Python 3 in windows PC in C directory like this:
C:\Python27 --> For Python2
C:\Python39 --> For Python3
After Installing Both Packages Go To Their Respective Folders And Copy python.exe & Paste In The Same Directory and rename the python - Copy with python2(In python27 folder) & python3(In python39 folder)
Python2:
Python3:
And Then Set Environment Vairable Like This:
All Done Now You Can Run Any Script Which May Compatible With Python2 or Python3 :)
I haven't used Python in a while, and only in Linux. Now on Windows, and just installed 3.7.4. I noticed immediately that python3.exe is not in the install directory, nor any of the pythonX.x.exe files, that are used for compatibility. I can only access Python through "python" from my command prompt, and old scripts that use Python 3 won't work.
Is there something I am missing here?
Of course, I can solve this for now by using symlinks, but is this an error in 3.7.4, or more likely, have I done something wrong in setting up my environment on Windows?
No, there's nothing wrong. This is just how Python is on Windows. There's the py launcher too that might help you out here.
https://docs.python.org/3/using/windows.html
3.2 The Microsoft Store Package
All three commands are also available with version number suffixes, for example, as python3.exe and python3.x.exe as well as python.exe (where 3.x is the specific version you want to launch, such as 3.7).
Virtual environments can be created with python -m venv and activated and used as normal.
If you have installed another version of Python and added it to your PATH variable, it will be available as python.exe rather than the one from the Microsoft Store. To access the new installation, use python3.exe or python3.x.exe.
I have python 3.2 installed and I want to know if I have to uninstall earlier versions before installing newer ones.
Install all the Python X.Y versions you want, but include Python 3.3 or later (last is best, or reinstall it after all the others) to get the Python Launcher that #abarnert mentioned in his comments. It is also available as a standalone installer.
Earlier versions than 3.3 should not register extensions, so the launcher installed by 3.3 or later will remain the default handler for .py files.
From the command line:
py -2 # launch latest 2.x version installed.
py -3 # latest 3.x
py -3.2 # run exact version
py -3.2-32 # run 32-bit version on 64-bit system.
So you can even have mixed 32-bit and 64-bit installations.
The environment variable PY_PYTHON can be set to specify the default Python to run.
In scripts, add a comment of the following forms below to use that version of Python when the script is double-clicked or run from command line via py script.py:
#!python2
#!python3
#!python3.2
#!python3.2-32
See PEP 397 for further details.
You can install multiple versions of Python on Windows, but only the last version you installed will be used by default: when double-clicking a .py file in Windows Explorer, when typing just python at the command line, etc. "Edit in IDLE" on the context menu also uses the last version you installed. To use other versions you'll need to specify the full path of the version you want. Also, if you use the PYTHONPATH environment variable, there's only one of those, and the scripts in the directories specified in PYTHONPATH may or may not work with whatever version of Python you happen to be running. This can be worked around by writing a batch file that sets PYTHONPATH before launching Python.
It generally depends on what OS you are running and how you installed your python. Under linux or Mac OSX, you don't need to unistall the previous version. I am not sure how things are handled for Windows.