I'm currently using SublimeText3 and R for my data analysis work. I simply open an R-REPL in Sublime Text and press CNTRL+Enter from a written script to evaluate a line of code. I would like to do this same process with Python, but when I try to send the Python script to the open Python REPL using CTRL+Enter, I receive the error "Cannot find REPL for R."
I believe this has something to do with my default path for the REPL in my user settings,
"default_extend_env": {"PATH": "{PATH};\\Program Files\\R\\R-3.1.0\\bin\\x64"}
However, I don't know how to generalize this to work with multiple environments. It would be very convenient for me to have Python and R scripts open and be able to send commands to their respective windows.
How do I fix this?
Related
I am working on a project using VBA, and have found that the best way to perform a certain function within it is with a python script (Pulling data from a web service via a user-inputted serial number, and then populating info associated with that serial in an excel sheet)(Probably the WHOLE thing should've been done in python, but I am not familiar with it, and am with VBA somewhat, so this is the path that was chosen). I have had some success with this by using pyinstaller to make the .py into a .exe, however this caused other issues, such as the script not functioning properly, and taking a while to run.
It is simple enough to run the actual python script via the anaconda3 prompt window. However, this will be used by others, so I would like it to be automatic such that, they only need to click on a VBA macro button, which then automatically runs the python script.
Any thoughts on how this can be achieved?
Thank you!
I'm relatively new to Python and was interested in learning if it's possible to interact with the Windows Command Line with Python (meaning able to directly input commands, such as dir or cd). I ask as I'm interested in making scripts to run in a Windows environment. I'm aware of the subprocess module, but I'm not sure if it has a routine for direct input.
Thanks.
I'd like to iteratively write and test my python code in the Python console. I can't find a way to easily load what i've got written in the editor (somefile.py) into the Python console in Pycharm. Is there a trick to doing so?
Pycharm will let me run the entire script but that's not useful because i want to build up my state in the shell by experimenting with the functions and data i've got in the environment (kind of like how a lisp programmer would use a REPL).
Pycharm have this alt-shift-E option.
This way you can write in the editor, select the lines you want to run and run them by alt-shift-E.
I use it all the time, although I find a lot of people not fameliar with this option.
in Sublime console one can execute arbitrary python code. But how can I select the current file buffer to execute commands on it? Like in a "on the fly" plugin.
EDIT
I wasn't clear in my question. I don't want to execute the Python code I'm programming, and I'm aware of SublimeREPL. I want to manipulate the text I'm writing (being it code or not) with Python, perhaps using Sublime API, to search, replace, manipulate text and so on just like you would do in a Sublime plugin, but one-off, just like you'd do with Elisp in Emacs.
Your best bet is to use SublimeREPL, also available through Package Control. The ST2 console just runs the internal Python version 2.6, and you can't use any third-party modules. SublimeREPL runs any Python interpreter you have installed on your machine, and basically acts just like the command-line version. It utilizes the full syntax highlighting and completion capabilities of ST2, and allows you to transfer bits or whole files of code to the REPL.
i've been searching about how to link visual basic with python file
i've tried so hard through using shell in Visual Basic but nothing happend
i have python file called Go.py and i want to link Visual Basic button with it and get the return into variable
any idea ?
First, you can use Shell, although it's unfortunately probably more complicated than you imagined.
Your current problem is a simple one - Shell can't run a python file directly, so you need to have Shell call cmd /c python.exe Go.py, and you may need to provide a full path to python.exe as well.
However, you also want to capture the result, and Shell only returns the process ID, not any kind of process output. You can check out some examples of external process invocation, although they don't explicitly cover how to capture output. If Go.py outputs to the terminal, you can probably capture the output into a file using standard Windows output redirection, and then open the file in VisualBasic and read the values.
You can also use System.Diagnostics.Process() instead of jumping through all the hoops of trying to get more functionality out of Shell. (Specifically, review the ProcessStartInfo class properties related to output redirection which give you much more control than anything using Shell will).