3

I have Python 2.7 installed and I have Anaconda (using Python 3.6) installed on Windows. Whenever I try to run my .py scripts from Windows outside of the Anaconda environment Windows defaults to using the Python 2.7 interpreter. My Scripts fail to import modules (i'm assuming this is using the wrong interpreter).

I have tried changing the path variable as per this post How should I set the default Python version in Windows and this post Changing python interpreter windows. I have also tried changing the default .exe from the 2.7 version to the Python.exe in Anaconda directly from the command line.

Is there anything I need to consider that Anacondas version is in "C:\Users\william\AppData\Local\Continuum\anaconda3\python.exe"? All other posts refer to Python.exe as being in something like "C://python27/". I am expecting to be able to set the default interpreter to use from the above location and set this to be the default for .py files.

Current Python Version:

enter image description here

Assuming this is from:

enter image description here

I am assuming I want to use this version:

enter image description here

I have tried adding the below to the user and system path variables:

enter image description here

WillD
  • 151
  • 1
  • 10
  • Any assistance on this? I am sure others must use Anaconda and have come across this. – WillD Jan 07 '19 at 17:30
  • Uninstalling all Python versions and re-installing with only the latest required version fixed my issue as per this post: https://stackoverflow.com/questions/5087831/how-should-i-set-the-default-python-version-in-windows?noredirect=1&lq=1 – WillD Jan 16 '19 at 11:30
  • Link to answer that answered my question: https://stackoverflow.com/a/34867186/5183415 – WillD Jan 24 '19 at 15:35

2 Answers2

0

Another solution which worked for me.

  • Open Command Prompt and type where python. For me:
C:\Users\user\anaconda3\python.exe
C:\Users\user\AppData\Local\Microsoft\WindowsApps\python.exe

I am going to use the first path to the python interpreter because it relates to Anaconda.

  • Following this tutorial, I added C:\Users\user\anaconda3\Scripts\ and C:\Users\user\anaconda3\ to the Path variable in the system variables section of Environment Variables.
Bunny
  • 1,180
  • 8
  • 22
0

I had the same issue. I tried first to remove the "C:\Users\user\AppData\Local\Microsoft\WindowsApps\python.exe" from my environment variables, and I unsinstalled python from the "Program" application. Then I added the following to my path environment variable.

C:\Users\user\anaconda3\Scripts\
C:\Users\user\anaconda3\

After doing that I could succesfully launch python from the command prompt using

python

and I got

Python 3.9.12 (main, Apr  4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)] :: 
Anaconda, Inc. on win32                                                                                                                                              
Warning:                                                                                                                
This Python interpreter is in a conda environment, but the environment has                                              
not been activated.  Libraries may fail to load.  To activate this 
environment                                          please see 
https://conda.io/activation                                                                                                                                                                                                          
Type "help", "copyright", "credits" or "license" for more information. 

with the warning message

mqax
  • 1
  • 2