Getting an R Notebook to work in Jetbrains Dataspell - python

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.

Related

Python isn't working at all. Jupyter Notebook can't connect to kernel and crashes, Spyder (via Anaconda) also crashes

Windows 11. I have an Anaconda installation of Python and use both Jupyter Notebook and Spyder occasionally. Everything was fine last week. Now suddenly, I have something similar happening to what's being described here: Jupyter Notebook - Cannot Connect to Kernel
But Spyder is also immediately crashing after opening. I tried conda update jupyter and conda update notebook, a substantial number of packages updated, but same problem. I also tried to revert tornado to 5.1.1 but that was incompatible with the current version of Python I have, 3.10.8.
I tried to search for some ill-named or placed Python scripts, but there really shouldn't be any, they're all in folders in the host Jupyter Notebook directory. And I don't really understand Python environments or want to keep track of them so I'd rather not attempt that (one of the answers of the previous post).
enter image description here

Develop Python with something like RStudio

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.

Why wouldn't Python code run in a Jupyter notebook when it runs in the terminal?

I've replicated Slack's API demo in a text editor and the terminal, but just for fun, I wanted to do it again using Jupyter notebook. I used the same virtual environment so as to rule-out dependency issues and the code was the same (cloned from the master repo). But for some reason, I'm always getting ModuleNotFound errors when I try to run the code in Jupyter cells and import the necessary packages.
I even re-built a fresh virtual environment, and ran the demo at a terminal from within Jupyter, and running the scripts works fine. I just doesn't execute in the notebook environment.
I'm using the same kernel across my Python interpreters, and I always start my virtualenv session before launching the notebook.
Anyone have any ideas why this would be the case?
Well, DUH. It was just a matter of uninstalling/reinstalling the package in a fresh virtual environment (and I'm pretty sure the latter wasn't absolutely necessary).
Thanks to this comment on Github for the guidance.

Pycharm jupyter notebook wsl: Jupyter package is not installed

I would like to use Jupyter notebook inside Pycharm. The project interpreter is a python2.7 from a virtual environment inside WSL (ubuntu 18.04).
The Jupiter package is correctly installed inside the virtual environment (I can run it by jupyter notebook).
My problem is that when I want to use Jupyter notebook inside Pycharm, I get the following error: Run Error Jupyter package is not installed (see picture).
Any idea what's going on here?
I had this problem in Python 3. Below are the steps I took to resolve the issue; I believe they should resolve the issue for you too:
I had Jupyter Lab installed. Pycharm only works with Jupyter Notebook. Long story short, if you have Jupyter Lab installed you need to uninstall all your packages using:
$ pip freeze | xargs pip uninstall -y
Restart your computer
Follow Jupyter Notebook installation instructions
Make sure WSL is set up through pycharm instructions: wsl pycharm instructions
In Pycharm, open an .ipynb file. Click the dropdown that says "Managed Jupyter server" It's right above the text editor. Select "configure Jupyter server". Check configured server.
In your wsl terminal, type jupyter notebook. Copy and paste the text that looks like: http://localhost:8888/?token=874asdf687asd6fasd8f74ds6f4s9d8f7sddf into the cofigured server box in Pycharm.
That's it. You should be able to run the jupyter cells in pycharm now.
I have Pycharm 2020.3 For me the issue was I was using a virtual environment with "inherit global site packages." I had Jupyter installed in global site packages but NOT the virtual environment.
Once I installed Jupyter within the virtual environment Jupyter notebook worked. Not sure why inheriting Jupyter from global packages wasn't working for me.
The above solution using a designated url with token seems to work with older versions of PyCharm. A simpler solution is to upgrade to the latest PyCharm. I no longer had an issue with the auto server using PyCharm 2019.3.2 (Mac)
I had this problem with Datalore plugin enabled on 2020.2 linux, running on bare metal but displaying to a remote X server (probably doesn't matter). My solution was to disable the Datalore plugin (it's enabled for professional pycharm by default).
This way I was still able to use the "managed" auto-start version with better integration / debugging vs the "configured" option (or at least with less hassle).
Note since it's been a year, my problem is probably different than OP.
This happened for me, when the interpreter was a remote one. I fixed this by changing the interpreter to one from a local env.
This can be done by selecting the Configure Jupyter Server.
I also meet this problem,and i solved it
i create the new project with the global sit-packages like below
then i meet the problem
i create the new project with no global sit-packages and install jupyter notebook in the virtualenv
then the problem is gone

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.

Categories