13

I am having trouble executing my anaconda python

It seems python is not associated correctly or not at all

I do not have admin rights as this is a work computer and going through IT takes forever

My anaconda is located in the C:\Users\dean.lemcke-evans\AppData\Local\Continuum\anaconda3

Here is the error I am getting how do I fix it?

code

Derlin
  • 9,572
  • 2
  • 32
  • 53
DeanLE
  • 131
  • 1
  • 1
  • 4

3 Answers3

18

To fix “File association not found for extension .py” on Windows, execute the following two commands in a cmd.exe with administrator privileges:

assoc .py=pyautofile
ftype pyautofile="C:\Anaconda2\python.exe" "%1" %*

Obviously edit the python.exe path above to where python.exe is found on your machine.

Reference: https://acloud.guru/forums/aws-dynamodb/discussion/-KWReio_6iBZoNMR4yoA/this-is-actually-an-answer-to-a-question-i-had-about-awscli-install-on-windows

profnotime
  • 301
  • 2
  • 9
  • 4
    He doesn't have admin rights. "I do not have admin rights as this is a work computer and going through IT takes forever" – Loaf Feb 18 '19 at 19:31
  • Also, please note the python executable path. In my case it was `ftype pyautofile="C:\ProgramData\Anaconda3\python.exe" "%1" %*` – Rafiq Nov 02 '19 at 17:01
  • Is there any possibility without admin permissions? – hey Nov 20 '19 at 19:27
  • This would be a very awkward solution if I change virtual environments often, wouldn't it? – ivan May 15 '20 at 14:16
0

I had to do the following (just another precursor to the above solution).

  1. Hit windows key and type cmd

  2. Right click on the cmd icon and choose run as an administrator

  3. Click on more choices (this is what is missing above)

  4. Enter the admin credentials.

  5. Copy paste the following and hit enter.

    assoc .py=pyautofile ftype pyautofile="C:\Anaconda2\python.exe" "%1" %*

Akash Yellappa
  • 2,126
  • 28
  • 21
0

If you want to execute this as python script below is the way. sys.executable will get python executable physical path, irrespective of os.

import sys

config_cmd= f'  ftype py_auto_file="{sys.executable}" "%1" %*' + '; assoc .py=py_auto_file '
config_cmd_out = subprocess.call(config_cmd, shell=True)
 if command_output == 0:
        logger.info(f'Success {command}')
    else:
        logger.error(f'Problem {command}')
Ram Ghadiyaram
  • 28,239
  • 13
  • 95
  • 121