Develop Python with something like RStudio - python

I'm looking for an IDE that can act like RStudio to develop Python applications in. I love being able to execute code chunks ad-hoc just to see what they do, change it a bit, look at the output again, etc. However, I also want the structure that Pycharm brings, being able to open an entire repo as a project. Does anyone have any recommendations?

Just update you Rstudio , in the newest version of Rstudio , version 1.4 you can develop with python
,
it installs a miniconda environment and then you can develop freely in python , in the environment Tab you will see that you will experience an ("R" like) experience of programming with Python .

Try Jupyter notebook, I think, it's what you want. Or you can run IPython notebooks in Pycharm e.g.

I personally hate Jupyter Notebooks. I'd recommend using Spyder, Pycharm, or VScode with extra emphasis on Spyder because it's python native and allows for remote connections for free (Pycharm is more sophisticated but you have to pay for the version that lets you connect to a remote kernel).
To execute a block of code in Spyder you just highlight what you want to run in the text editor and press f9. Spyder has similar repo/ file management capabilities as Pycharm.

Related

VS code is not running python

I am veryy new in coding and wanted to get into it. So I downloaded VS code. But I tried to run a very simple python command and it does not let me. See the picture below.
Visual Studio code is not an IDE, it is a code editor, which means you cannot run nor debug code naturally, for that you would need to run it on the windows terminal, or install extra packages and dependencies. If youre new and just want to learn Python, i suggest starting with a python IDE like the standard one provided or something more advanced like Pycharm, and if you want to program on VsCode and in multiple languages, search some tutorials about how to compile and run code on the windows terminal.
Provide more details about how you installed python from Microsoft Store, from anaconda or via its official page https://www.python.org/downloads/. Try running
python --version
or
python3 --version
If so you can run a python file from terminal. Assuming my file is called test.py
python test.py

Getting an R Notebook to work in Jetbrains Dataspell

So I am just starting a data science/stats class and I am trying to setup a R notebook within Dataspell I am able to create a Jupyter notbook but it only wants a python interpreter and I can't seem to change the interpreter to R
I only allows me to set a python interpreter. I am able to run R files just fine but I am trying to do it in a notebook. (Whether that be Jupyter or some other notebook I couldn't care less)
I would like to stick to Jetbrains IDE's either Dataspell or Pycharm. I tried our Datalore and got an R notebook working but its really slow for me.
Actually, there's an (currently - as of May 2022) undocumented feature in Dataspell 2022.1 which they have been developing which supports R kernels in Dataspell as an IDE.
If you have an Conda environment which has R and the irkernel installed and configured (for instance, if you set up your Anaconda environment to run Jupyter notebooks with the R kernel), you can open existing R notebooks in Dataspell and run them just like Python notebooks. The only thing you can't do is create new ones, sadly.
Basically, just use Anaconda or Miniconda to create an environment which can run Jupyter notebooks with the irkernel, create your notebooks in Jupyter, then point your Dataspell directory at it and it should work.
They do mention that it's a developing feature - so if you encounter bugs, you can flag them in the Dataspell issue tracker. I tried it and it worked pretty well so far.
You can see an example of my R kernel running in Dataspell here:
DataSpell can be a little difficult to navigate. In any case, File>New... pops up a menu:
Pick "RMarkdown File", which your purposes will work the same as a notebook. RStudio has both markdown and notebook options, but they still have an Rmd extension.
You should also see a R Console button at the bottom of the screen.

How do Windows Paths and Anaconda virtual environments work together?

I started my Python journey a month ago by following a guide which recommended installing Anaconda. Since then I've written/adapted some Jupyter Notebooks using VS Code and run them from within virtual environments. Recently I needed to run one of these Notebooks via from MS Access VBA and got to understand a little about using Python from the command line - specifically about using Environment Variable Path functionality in Windows to access Anaconda\Scripts and use things like activate to active virtual environments.
In the video guide it also recommended adding Anaconda3 to my Path so I could access python.exe. However, I've held off doing this because even after plenty of reading I'm still not clear on exactly the mechanics of of using this command when working with Anaconda virtual environments.
So to my question... say I add the Anaconda3 folder to my Path and then write something like python myscript.py presumably it runs the python.exe interpreter from the Anaconda3 folder? How will this work if I'm in a virtual environment that needs Python 3.7 but the interpreter I've loaded is actually Python 3.6? Does this even matter?
Please be assured I've read for a couple of hours on this before posting my question. Happy to read more if there is a layperson guide someone can point me towards. I've read through the Anaconda site.

Anaconda uses Jupyter notebooks so why option to install VS Code?

I installed Anaconda as it's a recommended way to start with Jupyter notebooks.
I was surprised at the end of the Anaconda windows install to be invited to install Microsoft VS Code as a code editor. Reading about VS Code it seems a well respected editor but does that not take away the idea of using using Jupyter notebooks? Or am I missing something?
Anaconda also installs IDLE and Spyder, which are IDEs (Integrated Development Environments). Anaconda simply gives you a choice. Each of those choices has its advantages and disadvantages. Using one does not prohibit you from also using another.
Jupyter might recommend using Anaconda, but this doesn't imply that Anaconda would recommend using Jupyter.
You are right that if you are going to focus on Jupyter notebooks you won't need to use VS Code.
But most people that use Anaconda are not using Jupyter notebooks - they write python scripts not notebooks - and for that vscode is a respected choice.

Why won't PyCharm see my libraries?

If I do something like "import selenium" (or any other kind of third party library) in a .py file and then run it from the terminal, it works just fine. But if I make a new file in PyCharm CE and do the same thing, it can't find the library / module.
How can I fix this or get it to point in the right location? I use a Macbook Pro.
You need to setup your project in PyCharm to use the Python interpreter that has your libraries:
Go to: file->settings->project->project interpreter
And select the appropriate interpreter from the dropdown. After selecting an interpreter, the window displays a list of libraries installed on that interpreter; this should further help you make the right selection.
I've faced a similar issue on Pop!_OS after installing PyCharm via Flatpak. I think the installation is somehow incomplete, as I've had these issues (among others):
Installer could not create the menu shortcut due to the lack of credentials. Unlike during a typical installation, it wouldn't ask for the password and instead I had to uncheck that option altogether.
Built-in terminal defaulted to sh. Even after changing to bash, it would not read my .bashrc and many commands were missing.
After changing the interpreter into a local virtualenv, it would just default to Python 3.7 (even though the version was actually 3.8) and it didn't see any of my installed libraries.
When I've tried to use a Docker Compose environment, IDE failed to detect Docker Compose installation.
I've eventually uninstalled PyCharm and downloaded it directly from Jetbrains website to make it work correctly.

Categories