Why my code does'nt execute on ipython notebook? - python

I am totally new to jupyter notebook and I was trying to run a simple code and its not working.
I typed print (1) and hit ctrl + enter, and then that asterisk mark appeared and thats pretty much it. there is a blinking "connected" in the console as well.
Command window looks like this:
Any tip regarding this would be highly appreciated. Thank you

yes, as Teemo pointed out all I had to do was use this,
C:\Python27\Scripts>jupyter notebook --port=8889
instead of,
C:\Python27\Scripts>jupyter notebook.
port 8889 , worked like a charm :)

using Jupyter on a VM, this was also for me the solution. Additionally, you can create a config file with:
jupyter notebook --generate-config
and search In your jupyter_notebook_config.py file for c.NotebookApp.port = 8888 (and change the port to 8889)
so you don't have to manually add the port every time jupyter is called.

I had the same issue and changing the host port didn't solve anything. I finally had to uninstalled the jupyter network package. I installed it has well through "pip install", I'd suggest to uninstall it as well using and only reinstalling it with the following through conda:
conda uninstall jupyter notebook
pip uninstall jupyter
pip3 uninstall jupyter
conda install jupyter notebook

Related

vscode Jupyter notebook run button missing

Everything works fine when I first open vscode and create a new Jupyter notebook
When I save and reopen it, the run button is gone.
I have added "jupyter.experiments.optOutFrom": ["NativeNotebookEditor"] to setting.JSON and still no change
python is installed
Jupyter notebook installed
How can I make it to work?
It looks weird, the appearance of the jupyter notebook in your question is different from mine:
In my memory, it looks like the older version of the jupyter notebook.
Could you provide more info about the jupyter notebook you are using? Like this:
And could you try to reinstall the Jupyter Notebook extension and disable other extensions which may be related to .ipynb file?
Use shift+enter and that should run the cell.
You should open the folder as a workspace and then, the button is shown. If you only open the file the result is that you can read the content, but not run the python code.
To elaborate on Steven-MSFT's answer, I saw that there was a button called "Reload Extension" indicated on this drawing below:
You can access this sidebar by entering cmd + shift + p, and then entering "Extensions: Install Extensions", as seen below:
Once I reloaded my Jupyter extension, all worked fine for me.
I had the same problem today. Uninstall and reinstall of "Jupyter" extension solved it.

How to fix Visual Studio Code Jupyter notebook error?

VScode for python runs perfectly, without any error, problems starts whenever I try to run Jupyter notebook inside VScode.
It starts with Ipython Kernel loading and then it shows Command Failed Error. Any fix for this ? I have no idea what's the problem and I don't know much about the environment and stuffs also.
Thank You.
From your picture, VSCode said Command failed, and it's a very long command. It mainly includes two parts: activate the conda base environment and change the vscode python environment through "Python" extension. And from the top right of the picture, it shows the jupyter server start failed.
So you can try to do two things:
First one: change the environment. Instead of using conda, download and install a global python from the official website. And recommend creating a virtual environment. Then select the environment instead of conda base environment.
Second one: reinstall or downgrade the 'Python' extension(if the first one not work).
This problem can be caused by the package in the environment, so I recommend you just change to another environment.

Jupyter - Not sure if not working or broken link

I am trying to open a notebook with jupyter, by using the following command:
jupyter notebook notebook.ipynb
I use Linux and python2, I have installed jupyter inside a virtualenvironment with pip.
When I run the command above, what happens is that I get a new screen
REFRESH(1 sec): http://localhost:8889/notebooks/mylink
This page should redirect you to Jupyter Notebook. If it doesn't, click here to go to Jupyter.
However, there is no dashboard opening automatically. So, I clicked on the link, but I am unable to connect. The weird think is that I don't remember what I did yesterday, but I managed to get through very easily.
Am I doing something wrong? Or maybe there is a problem with the link?
EDIT: If I run
jupyter notebook.ipynb
I get
Error executing Jupyter command 'notebook.ipynb': [Errno 2] No such file or directory
which does not make sense, because the file notebook.ipynb is actually there.
If I type
jupyter notebook stop
I get
There are no running servers
Happened to me too. Also their troubleshooting could not resolve the issue. You may note the This Worked An Hour Ago section.
If you are using environments, try creating a new environment and install jupyter notebook from scratch there. For Anaconda it would look like this:
conda create --name jupyter_env
conda activate jupyter_env
conda install -c conda-forge jupyterlab
jupyter notebook
You may change jupyter_env to a differen name of your liking.
What I usually do is run
jupyter notebook
and it will automatically open up the browser with my current directory. I then search for my notebook that way.
I guess one of these could help you fix this one:
change url to http://127.0.0.1:8889/notebooks/mylink or http://0.0.0.0:8889/notebooks/mylink
in case proxy or any other network settings set on your browser, disable them and check twice
if none of them did work, try to enter the url this way: http://localhost:8888/tree?
And, provide logs from console might help as well.
And one more thing, just to make sure, why you're connecting via port 8889? did you tried to run jupyter by --port command option?

How to specify python3 kernel in jupyter in pyCharm?

Here is my setting
and this is my script
I am trying to use jupyter notebook in pyCharm, but it kept using python2 instead of python3.
Any idea about this problem?
Add:
this pic is running jupyter notebook in chrome.
My problem was that I had multiple kernels, and PyCharm launches the default kernel. One approach might be to configure PyCharm to specify the kernel of choice to start up, I didn't investigate how to do that. I simply changed the default kernel in Jupyter and this worked for me (I have a virtualenv for tensorflow). c.MultiKernelManager.default_kernel_name = 'tensorflow'.
The preferences image you show is indeed how you would setup your interpreter for PyCharm, but that's not what the output/logging of PyCharm looks like. I'm guessing that's a jupyter-notebook display, which means you are running into the issue in jupyter-notebook and not PyCharm. So you need to change your setup for jupyter. Based on some quick searching pip install jupyter will install a python 2.7 version of jupyter. Sounds like what you want is
pip3 install jupyter
which will install the python3 version for you. You will likely have to uninstall your current version of jupyter.
When you kick off Jupyter-notebook from within PyCharm there is a configuration which is created. If the configuration is initially 2.7 ( I think it defaults to the current interpreter), and then keep using that same configuration, it wouldn't matter the state of the current project interpreter because it would be using the value saved in the run configuration.
You can modify your run configuration by
Run | Run...
Edit Configurations...
Select your Jupyter Notebook run configuration on the left (here is untitled4)
Make sure the python interpreter is correct here on the right
I was able to start a jupyter notebook like this and get it to output python 3 by doing this. Hope this is what you are needing.

Jupyter Notebook does not work fully in Pycharm

I am following these steps to run IPython in the Pycharm IDE. On pressing run button in any cell, I do get below pop-up window
According to the mentioned guide (given link), On pressing OK, I should get following message
But, I am not getting any type of message/response. So, I am not able to see the output of any cell contents. Does anyone know why I am not getting any response on selecting OK?
System Information:
OS: MAC OS 10.10.3
Python: 2.7.10 using Anaconda 2.3.0
Ipython: 4.0.0
Pycharm: pycharm community addition 2016.2
I solved following:
First I followed the reply to the issue jupyter-notebook No such file or directory: 'conda', in short you should do:
conda update nb_conda nb_conda_kernels nb_anacondacloud
Then, I ran my jupyter notebook in my browser. I took note where the Jupyter notebook was running, i.e.
The Jupyter Notebook is running at: http://localhost:8888/
Then I started a new Jupyter Notebook in PyCharm2016.2.2, and when it asked about the Jupyter Notebook URL I changed the default http://127.0.0.1:8888 to http://localhost:8888/
and finally it worked.
For the PyCharm Jupyter notebooks, to see results you need to open up a jupyter notebook.
The reason why you don't just do all your code in Jupyter Notebooks is because Pycharm helps with LaTex integration and many more functions.
According to this answer:
Jupyter notebook server not working with latest PyCharm 2017.2 update. How do I solve this?
You need a package named ”notebook“. I had the same issue and I solved it by installing the package.

Categories

Resources