spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.22k stars 1.59k forks source link

Request: Specify interpreter for dedicated console in run config #22022

Open pyZerrenner opened 5 months ago

pyZerrenner commented 5 months ago

Edit: Since I had last looked yesterday, a new issue #22020 with a similar suggestion was opened. Feel free to close my issue if you rather have a single issue on the topic.

Request Description

To switch the Python interpreter used for a console in Spyder is currently rather cumbersome by changing the setting (in Preferences > Python interpreter > "Use the following Python interpreter") for all subsequently started consoles. Would it be possible to add an option to the "Run configuration per file" dialog for selecting a specific interpreter when using the "Execute in a dedicated console" option? This would help when regularly switching between scripts that need specific virtual environments as the required interpreter has to be set only once. The default setting could be "Use interpreter in the preferences" instead of a fixed path to retain the current behaviour.

Relevant other issues, PRs, etc.

A similar request #1601 was already placed in an issue 9 years ago, which is still open but not active (I tried to commented there first). Also #22020 was created just before my request.

An easier selection of the interpreter for a new console was apparently implemented in #20421, but as of Spyder v5.5.4 that new menu is not yet available. This also only simplifies the issue for the "Execute in current console" option of the run configuration. A per-file interpreter selection could also apply to the "Execute in an external system terminal" option (I do not use this option, so I am not sure how helpful it would be).

The spyder-env-manager might be relevant for this topic in the future if it is still pursued. Though a per-file selection of the interpreter/environment would still be advantageous.

Specifying the interpreter on startup could be an possible solution by having a link to Spyder for each environment #18805. But running multiple instances of Spyder with different interpreters could become confusing and is not much less cumbersome than switching the interpreter in the preferences.

Versions ## Versions * Spyder version: 5.5.4 (conda) * Python version: 3.12.2 64-bit * Qt version: 5.15.8 * PyQt5 version: 5.15.9 * Operating System: Windows-10-10.0.19044-SP0 ### Dependencies ``` # Mandatory: atomicwrites >=1.2.0 : 1.4.1 (OK) chardet >=2.0.0 : 5.2.0 (OK) cloudpickle >=0.5.0 : 3.0.0 (OK) cookiecutter >=1.6.0 : 2.6.0 (OK) diff_match_patch >=20181111 : 20230430 (OK) intervaltree >=3.0.2 : 3.1.0 (OK) IPython >=8.13.0,<9.0.0,!=8.17.1 : 8.22.2 (OK) jedi >=0.17.2,<0.20.0 : 0.19.1 (OK) jellyfish >=0.7 : 1.0.3 (OK) jsonschema >=3.2.0 : 4.21.1 (OK) keyring >=17.0.0 : 25.1.0 (OK) nbconvert >=4.0 : 7.16.3 (OK) numpydoc >=0.6.0 : 1.7.0 (OK) paramiko >=2.4.0 : 3.4.0 (OK) parso >=0.7.0,<0.9.0 : 0.8.4 (OK) pexpect >=4.4.0 : 4.9.0 (OK) pickleshare >=0.4 : 0.7.5 (OK) psutil >=5.3 : 5.9.8 (OK) pygments >=2.0 : 2.17.2 (OK) pylint >=3.1,<4 : 3.1.0 (OK) pylint_venv >=3.0.2 : 3.0.3 (OK) pyls_spyder >=0.4.0 : 0.4.0 (OK) pylsp >=1.11.0,<1.12.0 : 1.11.0 (OK) pylsp_black >=2.0.0,<3.0.0 : 2.0.0 (OK) qdarkstyle >=3.2.0,<3.3.0 : 3.2.3 (OK) qstylizer >=0.2.2 : 0.2.2 (OK) qtawesome >=1.3.1,<1.4.0 : 1.3.1 (OK) qtconsole >=5.5.1,<5.6.0 : 5.5.1 (OK) qtpy >=2.1.0 : 2.4.1 (OK) rtree >=0.9.7 : 1.2.0 (OK) setuptools >=49.6.0 : 69.2.0 (OK) sphinx >=0.6.6 : 7.2.6 (OK) spyder_kernels >=2.5.1,<2.6.0 : 2.5.1 (OK) textdistance >=4.2.0 : 4.5.0 (OK) three_merge >=0.1.1 : 0.1.1 (OK) watchdog >=0.10.3 : 4.0.0 (OK) zmq >=24.0.0 : 25.1.2 (OK) # Optional: cython >=0.21 : 3.0.10 (OK) matplotlib >=3.0.0 : 3.8.4 (OK) numpy >=1.7 : 1.26.4 (OK) pandas >=1.1.1 : 2.2.2 (OK) scipy >=0.17.0 : 1.13.0 (OK) sympy >=0.7.3 : 1.12 (OK) ```
dalthviz commented 2 months ago

Hi @pyZerrenner sorry for such a late response! Thank you for the feedback and for summarizing the state of things! Just in case, regarding the menu to launch a console using a specific interpreter you can check https://github.com/spyder-ide/spyder/issues/22020#issuecomment-2211548343. Also, I would say that the last idea mentioned over https://github.com/spyder-ide/spyder/issues/1601#issuecomment-93843868 and the one you mention here (i.e adding a option to select the interpreter when the run from a dedicated console option is selected) makes sense :+1:

What do you think @spyder-ide/core-developers ? Also, should we make this issue supersede #1601 or maybe mark it as duplicate of #1601 and add #1601 to the wishlist milestone/add the help wanted label?