How to get Spyder to open python scripts (.py files) directly from Windows Explorer

后端 未结 8 470
無奈伤痛
無奈伤痛 2020-12-29 07:10

I have recently installed the Anaconda distribution on Windows 7 (Anaconda 3-2.4.0-Windows-x86_64). Unlike IDLE, I can\'t right-click and open a py file in the Spyder IDE. I

相关标签:
8条回答
  • 2020-12-29 07:41

    Right now there is no way to open a file in Spyder from the Windows File Explorer when using Anaconda. But we are working to have this functionality in a future version.

    It will work by adding an entry to the Open with menu you can see when doing a mouse right-click over a file on the Explorer.

    0 讨论(0)
  • 2020-12-29 07:42

    I figured I would post my solution for this as well.

    I have Spyder installed in multiple different environments. You can't simply call the spyder-script.py script without errors, because the environment must be activated.

    @echo off
    call [YOUR_CONDA_PATH]\Scripts\activate.bat [YOUR_CONDA_PATH]
    call conda activate [YOUR ENVIRONMENT]
    call start [YOUR_CONDA_PATH]\envs\[YOUR ENVIRONMENT]\pythonw.exe "[YOUR_CONDA_PATH]\envs\[YOUR ENVIRONMENT]\Scripts\spyder-script.py" %1
    

    You can remove the second line and remove the environment extension from the third line if you have Spyder installed in your base environment.

    Hopefully for anyone experiencing any weirdness with the other solution, this one will do the trick by activating the environment correctly.

    0 讨论(0)
提交回复
热议问题