File association not found for extension .py

Viewed 9192

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

3 Answers

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" %*

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}')
Related