Skip to content

Native REPL should allow for environment configuration #23570

Open

Description

@Apreche

For a lot of Python projects, in my case Django web projects, simply running a straight Python REPL isn't very helpful. There's a lot of environment setup and initialization that is required for the REPL to be useful within the context of the project. That's why there are facilities such as ./manage.py shell and with django-extensions ./manage.py shell_plus.

Those tools are already capable of launching different Python REPLs such as the default one, bpython and iPython. It would be great if they could seamlessly launch the VSCode native Python REPL in the same way.

Failing that, there should still be extensive configuration options for the native REPL. What directory does is run in? What environment variables to set automatically? What Python code to run automatically at the start of every REPL instance?

iPython profiles is a good place to start looking for what kinds of configuration options are desirable. Every time I have ever wanted to change the behavior of a Python REPL, I've found it was possible to do with iPython.

Activity

  1. anthonykim1 commented on Jun 17, 2024

    @anthonykim1

    Hello Scott Rubin (@Apreche), thanks much for your suggestions on improving the REPL experience. I kindly appreciate it.

    Failing that, there should still be extensive configuration options for the native REPL. What directory does is run in? What environment variables to set automatically? What Python code to run automatically at the start of every REPL instance?

    I do agree with you that equivalent or similar concept of IPython profiles would be great addition to the REPL experience, especially some sort of start up script that would run at the start of session which would allow users to automatically set their desired variables (such as environment variables) in a consistent manner. Or moreover, additional things that are listed in the example config file such as which scripts to automatically execute in each instance of iPython.

    In terms of django related, I believe there is already a feature request on this: #13027

  2. github-actions commented on Jul 17, 2024

    @github-actions

    Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.

    Happy Coding!

  3. jgorset commented on Aug 2, 2024

    @jgorset

    I think the bot closed this one by mistake, since there was no additional information requested by Anthony Kim (@anthonykim1), but rather an acknowledgement that it would be a neat feature. And, it really would be! So, should we reopen this? :)

  4. anthonykim1 commented on Aug 7, 2024

    @anthonykim1

    Johannes Gorset (@jgorset) Correct, let me reopen this with a better tag this time. Please upvote to show interest in this :)

  5. github-actions commented on Aug 7, 2024

    @github-actions

    Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.

  6. github-actions commented on Sep 7, 2024

    @github-actions

    Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.

    Happy Coding!

  7. anthonykim1 commented on Sep 8, 2024

    @anthonykim1

    I am keeping this opened since it already has over 9 votes.

  8. anthonykim1 commented on Dec 9, 2024

    @anthonykim1

    Related as well: #13027

  9. LewyCoda commented on Dec 23, 2024

    @LewyCoda

    I generally like how it looks comparatively to the usual terminal and I also like how it opens on the right side of vscode.
    I would like to know if there are any details regarding making it easier for me to use in relation to my current projects.
    For now however, I find it a bit harder to use with poetry as my environment is not interconnected with Python RELP or I just have little information regarding how to use it appropriately. My imports from my other scripts no longer work within the same file location of my script. My usual process was running python interpreter from the terminal and then hitting (shift + enter) to run selected lines and piecing them together one by one until I felt comfortable with the script running. Is it still possible to do something similar to this?

    Thank you and best regards

  10. anthonykim1 commented on Feb 4, 2025

    @anthonykim1

    Mr. Smith (@LewyCoda) Thanks for the feedback.
    It may be a case where you have not selected the virtual environment you created with poetry as an "active interpreter".
    Try running command Select interpreter in the command palette (ctrl/cmd +shift+ p) and make sure you select your desired poetry environment before launching the Native REPL.

    Image.

    . My usual process was running python interpreter from the terminal and then hitting (shift + enter) to run selected lines and piecing them together one by one until I felt comfortable with the script running. Is it still possible to do something similar to this?

    Yes, I'm thinking it may be easier to do this because the history of the cell execution are nicely divided into separate cell now, instead of having lists of undivided text in the terminal.
    If you have the setting python.REPL.sendToNativeREPL to true and python.REPL.enableREPLSmartSend (more description here: https://code.visualstudio.com/docs/python/run#_smart-send). The hope is that you will end up with smoother shift+enter workflow from your Python file to Native REPL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-replcommunity askFeature request that the community expressed interest infeature-requestRequest for new features or functionalityneeds community feedbackAwaiting community feedback

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions