spyder-ide / spyder

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

Feature request: per-project Python interpreter #11362

Open akdor1154 opened 4 years ago

akdor1154 commented 4 years ago

Related issues:

9804 (project settings, you guys are considering Conda envs which is a similar usecase)

1014 (exactly this, imported from google code and seemingly abandoned)

Currently interpreters are a global setting. It would be great to have a Python interpreter selectable as a project-level preference instead.

In #9804 it looks like you are considering allowing project-level Conda, but I don't use Conda. I just use a virtualenv per project (managed by poetry; pipenv users will have a similar/identical setup). This means I just want to set every project's interpreter to ./.venv/bin/python, relative to the project root.

For bonus points it would be nice to detect the existence of a pyproject.toml (https://www.python.org/dev/peps/pep-0518/), check if poetry is used (likewise for any other pyproject.toml-using tools), and if so then autoconfigure project interpreter to be the default under poetry env.

LeoWelter commented 4 years ago

may I say "me too". I was kind of expecting this would be in. As new user of Spyder i'm kind of disappointed since virtual env support is in pycharm and eclipse for ages now.

mhamiltonj commented 4 years ago

The lack of this feature means the team I work with is now migrating to PyCharm, despite the fact it has drawbacks for data science work. Keeping multiple team members' enviroments consistent with conda was just too cumbersome, so we switched to pipenv, only to find that dealing with different envirmoments in spyder requires manually changing the interpreter path in settings every time you switch project. Given that we all work on several projects, and often need to switch between them quickly, this is just not a usable workflow.

ccordoba12 commented 4 years ago

Sorry to hear that. Unless you and your team are willing to fund this feature, it'll come in Spyder 5 (to be released next year).

svdHero commented 4 years ago

@mhamiltonj we have exactly the same problem in our company. Switched to pipenv and wanted to migrate from PyCharm to Spyder, which is especially great for our physicists, because Spyder has such a Matlab-Feel to it. The only obstacle remaining is the need to manually change the interpreter path many times a day. So annoying and error-prone.

Spyder is great, but it definetely needs this feature in order to be of any significance in a professional work environment (pun intended :wink: ).

ccordoba12 commented 4 years ago

@svdHero, I said in my comment above:

Unless you and your team are willing to fund this feature, it'll come in Spyder 5 (to be released next year).

Unfortunately, this is not true anymore. Furthermore, we don't have plans to implement this now because it's been requested very little.

So, if this is important for your company, please consider to fund this work. You can contact me (my email address is in my profile) to discuss about it.

PackElend commented 3 years ago

there is a similar request, see #4223

svdHero commented 3 years ago

@ccordoba12 Unfortunately, funding is not possible, since we are a rather small electronics manufacturing company and the main focus is not Python. So management has no interest in investing into Python toolchain. Seems as if I will have to go back to VSCode until this feature makes it into Spyder.

I am sorry. I'd love our company to support open source projects. 😔

ccordoba12 commented 3 years ago

@svdHero, sorry to hear that. Unfortunately, we are a small team and this is kind of a big feature. We'll try to implement it for Spyder 6, to be released at the end of this year or the beginning of 2022.

mrclary commented 3 years ago

@ccordoba12, Since Spyder projects already create a .spyproject directory containing project configuration settings, it seems that the core configuration paradigm already exists and the bulk of the development work would just be implementing a project configuration interface. I imagine a Project Configuration window that would be something like a stripped down version of Spyder's preferences window, with the ability to select an interpreter (and set code style linting, and ...).

This, of course, would be quite a bit of work; but does this resemble what you were thinking could be included for Spyder 5?

ccordoba12 commented 3 years ago

Yes, that's basically the idea. We have a proposal for that dialog on issue #9804. However, we won't have time to include it for Spyder 5 (unless someone else helps us).

frafra commented 3 years ago

Wouldn't it be enough in some cases to add a command line option to use a specific python executable? Something like --use-current-python-interpreter and or --python-intepreter PATH?

It would be pretty easy just running spyder -p . --use-current-python-interpreter

Even without UI, having the Python interpreter configured in the project settings would be great!

Integration with Poetry seems more tricky, as spyder_kernels should be available in the virtual environment, but Poetry does not support using system installed packages (only in master).

trianta2 commented 3 years ago

I've been searching around for this feature request. I just installed Spyder 5.1.5 and I'm loving the improvements over Spyder 3. Kind of surprised that project-specific metadata such as the Python interpreter isn't available. Looking forward to when this feature is added.

ccordoba12 commented 3 years ago

This feature hasn't been implemented yet, sorry.

EvenGu commented 2 years ago

I'd like to request this feature as well. Once I create a spyder project, I would expect to be able to specify and save the interpreter associated so that I don't need to change it every time I work on another project in a different environment.

invokermain commented 2 years ago

This is a sorely needed feature, per project venv is best practice, using shared venv across many projects is not great and leads to many bad habits (one venv for everything, no per project dependency specification etc)

ccordoba12 commented 2 years ago

We'll try to implement this feature for Spyder 6, but the problem is that offering the ability to associate an environment with a project also intuitively demands a graphical way to manage packages in the env. And that's simply a much harder endeavor for which we don't have enough resources at the moment.

jonzhaopeng commented 2 years ago

We also need this feature, but we don't have money to donate. Maybe We have engineers to write code

ghost commented 2 years ago

I encountered this issue as well and have created a workaround for Windows in this gist to deal with this in the meantime. Perhaps it's useful for others.

wilecoyote2015 commented 2 years ago

We also need this feature. I've considered migrating from PyCharm to Spyder for scientific work several times in the last years, but this, along with missing PyCham-Like run-configurations, is always a showstopper, unfortunately.

AZippelius commented 1 year ago

I also really want this feature, and the lack makes working with multiple projects are real pain.

ghost commented 1 year ago

@AZippelius I think "a real pain" is exagerating a bit, but if you're really hindered by this you can use the gist I linked to earlier to work around this issue (on Windows).

AZippelius commented 1 year ago

@ba-tno As far as I can tell, that automatically selects the interpreter when starting Spyder, but not when switching projects inside spyder. So that would require a restart each time, which is only a marginal improvment.

ghost commented 1 year ago

@AZippelius That's correct, in my day to day work I rarely switch projects from within spyder. If I do, I simply launch a new instance (and maybe close the other one) with my script from a different directory with an environment file.

callegar commented 1 year ago

@ccordoba12

We'll try to implement this feature for Spyder 6, but the problem is that offering the ability to associate an environment with a project also intuitively demands a graphical way to manage packages in the env

Please, don't let this delay this useful feature. If I understand it correctly, as soon as the console in spyder gets associated with a virtual environment you already get a way to manage packages in the env from spyder almost for free: running pip or whatever tool is used for package management in the specific environment from the console.

gwerbin commented 1 year ago

@AZippelius I think "a real pain" is exagerating a bit, but if you're really hindered by this you can use the gist I linked to earlier to work around this issue (on Windows).

I would say it is indeed "a real pain" for some workflows, but not others. For example, not having this feature is basically a dealbreaker for me, and it's been the #1 thing keeping me away from using Spyder over the years (RStudio also lacks or lacked this feature for many years, and similarly I basically had to stop using it). I would love to see this implemented ASAP, because I do very much want to use Spyder.

I also strongly agree with @callegar in that you do not need GUI package management in order to make per-project environment/interpreter association useful, and that I hope the legitimate desire for the former does not delay the latter.

01tot10 commented 1 year ago

I'm in the process of trying to have my projects contained in separate (conda/mamba) environments, and ran into this limitation today. Wanted to give my thumbs up for the development team for considering this as a future feature!

mrclary commented 1 year ago

This feature is planned for Spyder 6.0 release later this year.

yuval-harpaz commented 2 weeks ago

This feature is planned for Spyder 6.0 release later this year.

Any updates? I am using Spyder 6.0.2 and can't see preferences per project. After PyCharm disaster (upgrade to Ubuntu 24.04 did not go well) I returned to Spyder but the lack of this feature is a major issue for me

ccordoba12 commented 2 weeks ago

@yuval-harpaz, sorry, we haven't had time to work on this. But it's really high in our todo list for 6.1, to be released in the first half of next year.