I'm using Python 3.6 through Spyder in Anaconda3.
I have both the Anaconda installation and a "clean" python installation.
Before I installed the "clean" python, when I ran the Python -V command in cmd I got the following version description Python 3.6.5 :: Anaconda, Inc. Now when I run the command it just says Python 3.6.5. and the pip list is a whole lot shorter.
When ever I open Spyder and find some package that I don't have... how would I go about installing said package?
If I just open cmd and write pip install ... it will install in the "clean" python directory.
How do I tell it to connect to Spyder?
I know it's a very late answer, but it may help other people.
When you are working with anaconda you can use the basic environement or create a new one (it may be what's you call a "clean" python installation). To do that just do the following :
Open you anaconda navigator
Go to "Environments"
Click on the button create. Here by the way you can choose you python version
Then to install your lib you can use your Anaconda GUI :
Double click on you environment
On the right side you have all you installed lib. In the list box select "Not installed"
Look for your lib, check it and click on "apply" on the bottom right
You can also do it in your windows console (cmd), I prefer this way (more trust and you can see what's going on) :
Open you console
conda activate yourEnvName
conda install -n yourEnvName yourLib
Only if your conda install did not find your lib do pip install yourLib
At the end conda deactivate
/!\ If you are using this way, close your Anaconda GUI while you are doing this
If you want you can find your environement(s) in (on Windows) C:\Users\XxUserNamexX\AppData\Local\Continuum\anaconda3\envs. Each folder will contains the library for the named environement.
Hope it will be helpfull
PS : Note that it is important to launch spyder through the Anaconda GUI if you want Spyder to find your lib
If you are using Spyder IDE easiest procedure which i found to install PIP is -:
Step 1- Check if Python is installed correctly.
The simplest way to test for a Python installation on your Windows server is to open a command prompt (click on the Windows icon and type cmd, then click on the command prompt icon). Once a command prompt window opens, type python and press Enter. If Python is installed correctly, you should see output similar to what is shown below:
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Step 2-: Now in Step 2
Once you’ve confirmed that Python is correctly installed, you can proceed with installing Pip.
Download get-pip.py
https://bootstrap.pypa.io/get-pip.py
to a folder on your computer.
Open a command prompt and navigate to the folder containing get-pip.py.
Run the following command:
python get-pip.py
Pip is now installed!
You can verify that Pip was installed correctly by opening a command prompt and entering the following command:
pip -V
You should see output similar to the following:
pip 18.0 from c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\pip (python 3.7)enter code here
There is a pip.exe included in the anaconda/Spyder package which can cleanly add mopdules to Spyder. It's not installed in the windows path by default, probably so it' won't interfere with the "normal" pip in my "normal" python package.
Check "/c/Users/myname/Anaconda3/Scripts/pip.exe". It seems to depend on local DLLs - it did not work (just hung) until I cd'd into it's directory. Once there I used it to install pymongo in the usual way, and the pymongo package was picked up by Spyder.
Hope that helps...
I installed spyder without anaconda on linux, and i was missing a module, all i did was installing pip on the linux terminal
sudo apt install python3-pip and then pip install "the library name "
and it worked in spyder without any other modification.
Related
I have in windows 10 64 bit installed python 3.9 with site-packages. I would like to install python 3.10.2 on windows 10 64 bit and find a way to install packages automatically in python 3.10.2, the same ones I currently have installed in python 3.9. I am also interested in the answer to this question for windows 11 64 bit.
I upgraded to python 3.10.2 in windows 10 64 bit. To properly install the packages, install the appropriate version of the Microsoft Visual C++ compiler if necessary. Details can be read https://wiki.python.org/moin/WindowsCompilers . With the upgrade to python 3.10.2 from 3.9, it turned out that I had to do it, due to errors that are appearing during the installation of the packages. Before the installing python 3.10.2, type and execute the following command in the windows command prompt:
pip freeze > reqs.txt
This command writes to the reqs.txt file the names of all installed packages in the version suitable for pip. If you run the command prompt with administrator privileges, the reqs.txt file will be saved in the directory C:\WINDOWS\system32.
Then, after the installing of python 3.10.2 and the adding it to the paths in PATH, with the help of the command prompt you need to issue the command:
pip install -r reqs.txt
This will start the installing of the packages in the same versions as for python 3.9. If problems occur, e.g. an installation error appears during the installation of lxml, then you can remove from the regs.txt file the entry with the name of the package whose installation is causing the problem and then install it manually. To edit the reqs.txt file you need the administrator privileges. The easiest way is to run the command prompt in the administrator mode, type reqs.txt and click Enter to edit it.
I decided later to update the missing packages to the latest version, because I suspected that with python 3.10.2 older versions were not compatible.
This means that when upgrading to python 3.10.2 it is worth asking yourself whether it is better to upgrade for all packages. To do this, you can generate the list of the outdated packages using the command:
pip list –-outdated
After the printing of the list in the command prompt, you can upgrade the outdated packages using the command:
pip install --upgrade <package-name>
This can be automated by the editing of the reqs.txt file and the changing of the mark == to > which will speed up the upgrade. The mark > should only be changed for the outdated packages or you will get an error: "Could not find a version that satisfies the requirement ... ".
Supplement to virtual environments:
When you enter a virtual environment directory (in the windows command prompt):, such as D:\python_projects\data_visualization\env\Scripts, type activate to activate it. Then create the reqs.txt file analogous to the description above. Then, copy the file to a temporary directory. After this delete the virtual environment, e.g. using the windows explorator by the deleting of the contents of the env directory. Then, using the version of python in windows of our choice, create a virtual environment using the env directory (see: https://docs.python.org/3/library/venv.html). Copy the regs.txt file to the newly created D:\python_projects\data_visualization\env\Scripts directory. Install site-packages with the support of the regs.txt file as described above.
No you need not reinstall python packages.
conda create --name project-env python=3.x
You can also look at an alternative method to install python versions Install python version
When following the Installing TensorFlow for Windows guide https://www.tensorflow.org/install/install_windows, after executing
C:\> pip3 install --upgrade tensorflow
I get the following error:
'pip3' is not recognized as an internal or external command,
It looks like pip3 isn't recognized at all (although PATH to python is set)
Run the following
python -m pip install --upgrade tensorflow
Assuming python is working, TensorFlow should get installed (at least the "Validate the installation" step is green).
This will work, if you are facing pip3 or pip is not recognized as an internal or external command issue on windows:
From the desktop, right click the Computer icon.
Choose Properties from the context menu.
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit.
A new pop up will open. Variable name will remain Path. We will change the Variable value to the location of the folder where your python scripts folder is located. Find it.
For e.g. I changed its value to C:\Users\rgupta6\AppData\Local\Programs\Python\Python35\Scripts
Close all remaining windows. Reopen Command prompt window, and run your pip3 install --upgrade tensorflow command or pip3 install tensorflow command
That is because you haven't setup the environment variable yet.
Follow the steps by #rajesh
I had the same problem and i found his answer helpful
Right click on This PC > Select Properties
Select Advanced system settings on the left
In the dialog box select Environment Variables
In the system variables section select path and cllck on edit
Select new and enter the path where the python scripts are..
it is mostly in C:\Users[your user name]\AppData\Local\Programs\Python\Python36\Scripts
Then ok.. to all the boxes opened
Close cmd if it is already open and now try installing tensorflow using pip again like this
pip3 install --upgrade tensorflow
Before running pip3 install --upgrade tensorflow
you need check if you are using the correct Python 3.5 installation:
Python 3.5.2 [MSC v.1900 64 bit (AMD64)] on win32
Notice the 64 bit part.
Otherwise, it gives the above error.
You are going to install tensorflow-1.0.1-cp35-cp35m-win_amd64.whl, therefore double check your correct version (mostly this is happening you have both Python 2.7 and 3.5).
when installing python, on the install window, check the box "Active path"(something like that), which builds up a path link. So you can run "pip3 install" at anywhere.
Typing the python command before that should do the trick. In my case (on Windows 8.1 with Python 3.6), I had to type 'py' instead of 'python' as follows:
py -m pip install --upgrade tensorflow
The answer depends on the system you're using.
The issue is your path in the cmd is not that of where your python scripts are placed. In this case you can either navigate to "AppData\Local\Programs\Python\Python36\Scripts" in your terminal and then run the command or you can simply put C:\Users\Your User Name\AppData\Local\Programs\Python\Python36\Scripts to Path variable.
Then re-launch your cmd and type "pip3 install tensorflow" and see the feel the happiness :)
I just experienced the same issue, most likely you downloaded a zipped version of python, then unzipped it, and added it to $PATH just like me, python can work but pip3 cannot, and python -m pip cannot either.
fix solution is to download a executable version of python, then follow common installation steps, pip3 is selected by default, then everything is OK now.
I have Anaconda installed (Python 2.7.11 |Anaconda custom (64-bit)| (default, Feb 16 2016, 09:58:36) [MSC v.1500 64 bit (AMD64)] on win32) and I am using Spyder 2.3.8
Would like to update Spyder to the latest version, so I went through the commands:
conda update conda
conda update anaconda
conda update spyder
They all ran without errors, but the spyder version didn't change - this is command I'm using to launch:
C:\Anaconda2\pythonw.exe C:\Anaconda2\cwp.py C:\Anaconda2 "C:/Anaconda2/pythonw.exe" "C:/Anaconda2/Scripts/spyder-script.py" --new-instance
Am I missing something?
To expand on juanpa.arrivillaga's comment:
If you want to update Spyder in the root environment, then conda update spyder
works for me.
If you want to update Spyder for a virtual environment you have created (e.g., for a different version of Python), then conda update -n $ENV_NAME spyder where $ENV_NAME is your environment name.
EDIT: In case conda update spyder isn't working, this post indicates you might need to run conda update anaconda before updating spyder. Also note that you can specify an exact spyder version if you want.
Go to Anaconda Naviagator, find spyder,click settings in the top right corner of the spyder app.click update tab
I see that you used pip to update. This is strongly discouraged (at least in Spyder 3). The Spyder update notices I receive have always included the following:
"IMPORTANT NOTE: It seems that you are using Spyder with Anaconda/Minconda. Please don't use pip to update it as that will probably break your installation. Instead please wait until new conda packages are available and use conda to perform the update."
Use this conda install spyder=4.0.0
This will not mess up your anaconda dependencies.
https://github.com/spyder-ide/spyder/releases
Simply select 'Update Application' after clicking on the settings symbol(top right corner) for Spyder in the Anaconda Navigator console. In my case I just updated it so it's in disabled state.
use this command
conda install spyder=5.0.1
this will install the new version or tell you the error
PackagesNotFoundError: The following packages are not available from
current channels
How to solve the error
1- update your anaconda
conda update anaconda
2- go to anaconda then spyder
or use this command
conda install spyder=5.0.0
make sure you in your base directory.
then conda install spyder will work.
Do it like this: conda install spyder=new_version_number.
new_version_number should be in digits.
One way to avoid errors during installing or updating packages is to run the Anaconda prompt as Administrator. Hope it helps!
You can easily install update version if you use Anaconda by closing Spyder and then running the following command in a system terminal (Anaconda Prompt on Windows, xterm on Linux or Terminal.app on macOS):
conda install spyder= Your desire version
(For example, Version is 3.1)
conda install spyder=3.1
Or you can use pip with this command in a system terminal (cmd.exe on Windows, xterm on Linux or Terminal.app on macOS):
pip install --pre -U spyder
Note: Do not use this command if you are using Anaconda because it could break your installation.
Using pip directly:
WARNING: This will break your Anaconda Installation as described by Spyder maintainer in the comments below; you can try this solution only if the solution mentioned above that use Conda do not work
pip install --upgrade spyder
You might get an error once launching the new Spyder "nbconvert >= 4.0: None (NOK)", which will require you to resinstall configparser:
conda uninstall configparser
conda install configparser
You should now have a fresh and up to date installation of Spyder.
In iOS,
Open Anaconda Navigator
Launch Spyder
Click on the tab "Consoles" (menu bar)
Then, "New Console"
Finally, in the console window, type conda update spyder
Your computer is going to start downloading and installing the new version. After finishing, just restart Spyder and that's it.
It's very easy just in 2 click
Open Anaconda Navigator
Go to Spyder icon
Click on settings logo top-right coner of spider box
Click update application
That it
Happy coding
My solution was uninstalla spyder and installa again.
Solved my problem:
conda uninstall spyder
conda install spyder=5
As I understand, Python 2.7.9 comes with Pip installed, however when I try to execute a Pip command from CMD (Windows) I get the following error:
'pip' is not recognized as an internal or external command, operable program or batch file.
When I type python I do get the following, which suggests it has been installed correctly:
Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
I did however need to add some environmental variables to get the python part working on CMD:
Add to the environment variable PATH: "C:\Python27\"
Define the system variable PYTHONPATH: "C:\Python27\"
I cannot find a Pip folder within the Python directory, however there is a folder called "ensurepip" in C:\Python27\Lib\.
Does anybody know how can I get Pip commands to start working in CMD?
Little side note for anyone new to Python who didn't figure it out by theirself: this should be automatic when installing Python, but just in case, note that to run Python using the python command in Windows' CMD you must first add it to the PATH environment variable, as explained here.
To execute Pip, first of all make sure you have it installed, so type in your CMD:
> python
>>> import pip
>>>
And it should proceed with no error. Otherwise, if this fails, you can look here to see how to install it. Now that you are sure you've got Pip, you can run it from CMD with Python using the -m (module) parameter, like this:
> python -m pip <command> <args>
Where <command> is any Pip command you want to run, and <args> are its relative arguments, separated by spaces.
For example, to install a package:
> python -m pip install <package-name>
Newer versions of Python come with py, the Python Launcher, which is always in the PATH.
Here is how to invoke pip via py:
py -m pip install <packagename>
py allows having several versions of Python on the same machine.
As an example, here is how to invoke the pip from Python 2.7:
py -2.7 -m pip install <packagename>
Make sure to also add "C:\Python27\Scripts" to your path. pip.exe should be in that folder. Then you can just run:
C:\> pip install modulename
Go to the folder where Python is installed .. and go to Scripts folder .
Do all this in CMD and then type :
pip
to check whether its there or not .
As soon as it shows some list it means that it is there .
Then type
pip install <package name you want to install>
Simple solution that worked for me is, set the path of python in environment variables,it is done as follows
Go to My Computer
Open properties
Open Advanced Settings
Open Environment Variables
Select path
Edit it
In the edit option click add and add following two paths to it one by one:
C:\Python27
C:\Python27\Scripts
and now close cmd and run it as administrator, by that pip will start working.
Firstly make sure that you have installed python 2.7 or higher
Open Command Prompt as administrator and change directory to python and then change directory to Scripts by typing cd Scripts then type pip.exe and now you can install modules
Step by Step:
Open Cmd
type in "cd \" and then enter
type in "cd python2.7" and then enter
Note that my python version is 2.7 so my directory is that so use your python folder here...
type in "cd Scripts" and enter
Now enter this "pip.exe"
Now it prompts you to install modules
In my case I was trying to install Flask. I wanted to run pip install Flask command. But when I open command prompt it I goes to C:\Users[user]>. If you give here it will say pip is not recognized. I did below steps
On your desktop right click Computer and select Properties
Select Advanced Systems Settings
In popup which you see select Advanced tab and then click Environment Variables
In popup double click PATH and from popup copy variable value for variable name PATH and paste the variable value in notepad or so and look for an entry for Python.
In my case it was C:\Users\[user]\AppData\Local\Programs\Python\Python36-32
Now in my command prompt i moved to above location and gave
pip install Flask
This is the simplest way.
Within Command Prompt:
py -m pip install <ModuleNameGoesHere>
This will run anywhere as long as you have python installed.
Breakdown:
py is a universal python command for most versions of Python. Which is nice because you don't have to find and navigate to a specific or complex path.
-m stands for module
pip is the package management system used to install and manage software packages written in Python
install is the Pip command for installation
ModuleName... is the placeholder for the module/package object you wish to download into python.
Example:
py -m pip install requests
or py -m pip install pandas
I have a Python 2.7.11 installed on one of my LAB stations. I would like to upgrade Python to at least 3.5.
How should I do that ?
Should I prefer to completely uninstall 2.7.11 and than install the new one ?
Is there a way to update it ? Is an update a good idea ?
Every minor version of Python, that is any 3.x and 2.x version, will install side-by-side with other versions on your computer. Only patch versions will upgrade existing installations.
So if you want to keep your installed Python 2.7 around, then just let it and install a new version using the installer. If you want to get rid of Python 2.7, you can uninstall it before or after installing a newer version—there is no difference to this.
Current Python 3 installations come with the py.exe launcher, which by default is installed into the system directory. This makes it available from the PATH, so you can automatically run it from any shell just by using py instead of python as the command. This avoids you having to put the current Python installation into PATH yourself. That way, you can easily have multiple Python installations side-by-side without them interfering with each other. When running, just use py script.py instead of python script.py to use the launcher. You can also specify a version using for example py -3 or py -3.6 to launch a specific version, otherwise the launcher will use the current default (which will usually be the latest 3.x).
Using the launcher, you can also run Python 2 scripts (which are often syntax incompatible to Python 3), if you decide to keep your Python 2.7 installation. Just use py -2 script.py to launch a script.
As for PyPI packages, every Python installation comes with its own folder where modules are installed into. So if you install a new version and you want to use modules you installed for a previous version, you will have to install them first for the new version. Current versions of the installer also offer you to install pip; it’s enabled by default, so you already have pip for every installation. Unless you explicitly add a Python installation to the PATH, you cannot just use pip though. Luckily, you can also simply use the py.exe launcher for this: py -m pip runs pip. So for example to install Beautiful Soup for Python 3.6, you could run py -3.6 -m pip install beautifulsoup4.
If you are upgrading any 3.x.y to 3.x.z (patch) Python version, just go to Python downloads page get the latest version and start the installation. Since you already have Python installed on your machine installer will prompt you for "Upgrade Now". Click on that button and it will replace the existing version with a new one. You also will have to restart a computer after installation.
If you are upgrading from 3.x to 3.y (minor) then you will be prompted with "Install Now". In this case, you are not upgrading, but you are installing a new version of Python. You can have more than one version installed on your machine. They will be located in different directories. When you have more than one Python version on your machine you will need to use py lanucher to launch a specific version of Python.
For instance:
py -3.7
or
py -3.8
Make sure you have py launcher installed on your machine. It will be installed automatically if you are using default settings of windows installer. You can always check it if you click on "Customize installation" link on the installation window.
If you have several Python versions installed on your machine and you have a project that is using the previous version of Python using virtual environment e.g. (venv) you can upgrade Python just in that venv using:
python -m venv --upgrade "your virtual environment path"
For instance, I have Python 3.7 in my ./venv virtual environment and I would like upgrade venv to Python 3.8, I would do following
python -m venv --upgrade ./venv
Installing/Upgrading Python Using the Chocolatey Windows Package Manager
Let's say you have Python 2.7.16:
C:\Windows\system32>python --version
python2 2.7.16
...and you want to upgrade to the (now current) 3.x.y version. There is a simple way to install a parallel installation of Python 3.x.y using a Windows package management tool.
Now that modern Windows has package management, just like Debian Linux distributions have apt-get, and RedHat has dnf: we can put it to work for us! It's called Chocolatey.
What's Chocolatey?
Chocolatey is a scriptable, command line tool that is based on .NET 4.0 and the nuget package manager baked into Visual Studio.
If you want to learn about Chocolatey and why to use it, which some here reading this might find particularly useful, go to https://chocolatey.org/docs/why
Installing Chocolatey
To get the Chocolatey Package Manager, you follow a process that is described at https://chocolatey.org/docs/installation#installing-chocolatey,
I'll summarize it for you here. There are basically two options: using the cmd prompt, or using the PowerShell prompt.
CMD Prompt Chocolatey Installation
Launch an administrative command prompt. On Windows 10, to do this:
Windows + R
Type cmd
Press Ctrl + ⇧ Shift + ↵ Return
If you don't have administrator rights on the system, go to the Chocolatey website. You may not be completely out of luck and can perform a limited local install, but I won't cover that here.
Copy the string below into your command prompt and type Enter:
#"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
Chocolatey will be downloaded and installed for you as below:
Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.11.
Downloading 7-Zip commandline tool prior to extraction.
Extracting C:\Users\blahblahblah\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\blahblahblah\AppData\Local\Temp\chocolatey\chocInstall...
Installing chocolatey on this machine
Creating ChocolateyInstall as an environment variable (targeting 'Machine')
Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'
WARNING: It's very likely you will need to close and reopen your shell
before you can use choco.
Restricting write permissions to Administrators
We are setting up the Chocolatey package repository.
The packages themselves go to 'C:\ProgramData\chocolatey\lib'
(i.e. C:\ProgramData\chocolatey\lib\yourPackageName).
A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin'
and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'.
Creating Chocolatey folders if they do not already exist.
WARNING: You can safely ignore errors related to missing log files when
upgrading from a version of Chocolatey less than 0.9.9.
'Batch file could not be found' is also safe to ignore.
'The system cannot find the file specified' - also safe.
chocolatey.nupkg file not installed in lib.
Attempting to locate it from bootstrapper.
PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding...
WARNING: Not setting tab completion: Profile file does not exist at 'C:\Users\blahblahblah\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'.
Chocolatey (choco.exe) is now ready.
You can call choco from anywhere, command line or powershell by typing choco.
Run choco /? for a list of functions.
You may need to shut down and restart powershell and/or consoles
first prior to using choco.
Ensuring chocolatey commands are on the path
Ensuring chocolatey.nupkg is in the lib folder
Either Exit the CMD prompt or type the following command to reload the environment variables:
refreshenv
PowerShell Chocolatey Installation
If you prefer PowerShell to the cmd prompt, you can do this directly from there, however you will have to tell PowerShell to run with a proper script execution policy to get it to work. On Windows 10, the simplest way I have found to do this is to type the following into the Cortana search bar next to the Windows button:
PowerShell.exe
Next, right click on the 'Best Match' choice in the menu that pops up and select 'Run as Administrator'
Now that you're in PowerShell, hopefully running with Administrator privileges, execute the following to install Chocolatey:
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
PowerShell will download Chocolatey for you and launch the installation. It only takes a few moments. It looks exactly like the CMD installation, save perhaps some fancy colored text.
Either Exit PowerShell or type the following command to reload the environment variables:
refreshenv
Upgrading Python
The choco command is the same whether you use PowerShell or the cmd prompt. Launch your favorite using the instructions as above. I'll use the administrator cmd prompt:
C:\WINDOWS\system32>choco upgrade python -y
Essentially, chocolatey will tell you "Hey, Python isn't installed" since you're coming from 2.7.x and it treats the 2.7 version as completely separate. It is only going to give you the most current version, 3.x.y (as of this writing, 3.7.2, but that will change in a few months):
Chocolatey v0.10.11
Upgrading the following packages:
python
By upgrading you accept licenses for the packages.
python is not installed. Installing...
python3 v3.x.y [Approved]
python3 package files upgrade completed. Performing other installation steps.
Installing 64-bit python3...
python3 has been installed.
Installed to: 'C:\Python37'
python3 can be automatically uninstalled.
Environment Vars (like PATH) have changed. Close/reopen your shell to
see the changes (or in powershell/cmd.exe just type `refreshenv`).
The upgrade of python3 was successful.
Software installed as 'exe', install location is likely default.
python v3.x.y [Approved]
python package files upgrade completed. Performing other installation steps.
The upgrade of python was successful.
Software install location not explicitly set, could be in package or
default install location if installer.
Chocolatey upgraded 2/2 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Either exit out of the cmd/Powershell prompt and re-enter it, or use refreshenv then type py --version
C:\Windows\System32>refreshenv
Refreshing environment variables from registry for cmd.exe. Please wait...Finished..
C:\Windows\system32>py --version
Python 3.7.2
Note that the most recent Python install will now take over when you type Python at the command line. You can run either version by using the following commands:
py -2
Python 2.7.16 (v2.7.16:413a49145e, Mar 4 2019, 01:37:19) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
C:\>py -3
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>exit()
C:\>
From here I suggest you use the Python pip utility to install whatever packages you need. For example, let's say you wanted to install Flask. The commands below first upgrade pip, then install Flask
C:\>py -3 -m pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/d8/f3/413bab4ff08e1fc4828dfc59996d721917df8e8583ea85385d51125dceff/pip-19.0.3-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 1.6MB/s
Installing collected packages: pip
Found existing installation: pip 18.1
Uninstalling pip-18.1:
Successfully uninstalled pip-18.1
Successfully installed pip-19.0.3
c:\>py -3 -m pip install Flask
...will do the trick. Happy Pythoning!
A quick and painless way for me was to do the following:
Do a pip freeze > requirements.txt on my affected environments (or whatever method you want for backing up your requirements)
Remove the Old version of Python (in my case it was 3.8)
Remove the associated environments
Install the new version (3.9.5 in my case)
Recreate my environments python -m venv venv or however you wish
Reinstall my plug-ins/apps pip install -r requirements.txt or however you wish
Python 2.x and Python 3.x are different. If you would like to download a newer version of Python 2, you could just download and install the newer version.
If you want to install Python 3, you could install Python 3 separately then change the path for Python 2.x to Python 3.x in Control Panel > All Control Panel Items > System > Advanced System Settings > Environment Variables.
In 2019, you can install using chocolatey. Open your cmd or powershell, type:
choco install python
Nowadays you can just install several Python versions from Microsoft Store. Those are published there by Python Software Foundation.
https://apps.microsoft.com/store/search?hl=en-en&gl=EN&publisher=Python%20Software%20Foundation
Just install python newest version's installer it will automatically detect your python version and will say upgrade python and starts upgrading
I was able to execute PowerShell with the following command and python upgraded with no issue. python -m pip install --upgrade pip please see image
You can use pyenv. It let you easily switch between all versions of python.