How can I execute Python scripts using Anaconda's version of Python?

前端 未结 7 861
北海茫月
北海茫月 2020-12-24 02:07

I recently downloaded the Anaconda distribution for Python. I noticed that if I write and execute a Python script (by double-clicking on its icon), my computer (running on W

7条回答
  •  粉色の甜心
    2020-12-24 02:31

    The instructions in the official Python documentation worked for me: https://docs.python.org/2/using/windows.html#executing-scripts

    1. Launch a command prompt.

    2. Associate the correct file group with .py scripts:

      assoc .py=Python.File
      

    Redirect all Python files to the new executable:

        ftype Python.File=C:\Path\to\pythonw.exe "%1" %*
    

    The example shows how to associate the .py extension with the .pyw executable, but it works if you want to associate the .py extension with the Anaconda Python executable. You need administrative rights. The name "Python.File" could be anything, you just have to make sure is the same name in the ftype command. When you finish and before you try double-clicking the .py file, you must change the "Open with" in the file properties. The file type will be now ".py" and it is opened with the Anaconda python.exe.

提交回复
热议问题