Different Environment of Anaconda Prompt and Jupyter Notebook - python

I have always been executing my python script through a drag and drop approach to the anaconda prompt as the script is executed in the anaconda environment. I have this script in which it should be executed on another pc through a drag and drop approach in that pc's anaconda prompt. Turns out a certain library wasn't able to be imported. I tried running the script on jupyter notebook in that PC and it works. This would be the first time that I feel that anaconda prompt and jupyter notebook aren't running in the same environment.
Any help would greatly be appreciated, thanks!!

Every time you start you anaconda prompt, if you don't change your enviornment, it will be default in 'base' environment.
And I don't know where your run your jupyternotebook, but you may double check which anaconda environment it is running with.
PS: Since i am still not able to comment. I will write the reply here, hope it helps you a bit.

Related

Jupyter notebooks in VSCode not showing up to date python kernel list

For a couple of months I've had issues with working with virtual envs, python notebooks & jupyter in VSCode, for some reason, a lot of the time, it cannot find kernels I added, even though I can see them when running jupyter kernelspec list. It seems random whether they appear or not. Reloading the screen and restarting vscode does not help, neither does disabling and re-enabling the python and jupyter extensions. I tried both from the button, select kernel and through the command palette. I usually start vscode from the command line, with my virtual environment activated. Moreover, a lot of kernels which I've deleted a long time ago still show up in the list.
Vscode and laptop are both up to date.
I've had issues with the integrated jupyter notebooks before, at first formatting and autocomplete didn't work in the notebook (but they did in regular python files).
I'm on MacOS, if that matters.
Sorry to tell that this is a bug, see bug report:
Can't see or select Jupyter kernel's from Kernel drop-down
And now there's a workaround that:
Find where python is installed
Select the command Python: Select Interpreter
Next select Enter interpreter path
Next enter the path into the input box and hit Enter
This interpretr will now work in VS Code and you might need to re-load
VS Code just once more to get it working in jupyter extension.
Please have a try.

Jupyter Notbooks not launching

I'm running Python 3.8 (Anaconda) on Windows 10 and have previously not had any issues launching Jupyter Notebooks. Today that changed: When I tried to launch it from the Anaconda Navigator, it suggested that it launched it but didn't open anything in my default browser (Chrome), so nothing really happened. Also, not terminal prompt was launched. When I tried launching it from the command line, typing both jupyter notebook and jupyter-notebook it launches the notbook but only in the background (ie. it provides a link that I need to copy into my browser). I find this quite strange and am trying to understand what's going on. My hunch is that it's some kind of Windows related issue but I'd like to know what issue.
So my question is what can explain this behaviour? And assuming that this is related to some strange Windows issue, I'd be keen to find out what it is.
I replicated the exact steps I used to always launch it (which worked), so this shouldn't be anything to do with the setup.
Cheers!

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.

How do you change environment of Python Interactive on Vscode?

I recently migrated from Spyder to VScode. I created a new conda environment and used setting.json to change the environment in VScode, "python.pythonPath": "/Users/dcai/anaconda3/envs/alphalens/bin/python"
However when I tried to run the code in Python Interactive, a different environment was loaded.
Is there a way for me to change the Python Interactive environment and match it to my terminal environment?
The Python Interactive window should be starting up using the Python version selected in the lower left corner of the VS Code IDE. This is the same environment that you can also pick via the Python: Select Interpreter command palette option. However the Python Interactive window does do one thing differently here. If the currently selected environment does not have jupyter installed it will look in the other environments for one that does and launch it, you should see a warning message in this case that a different environment was used.
Did this help answer your question? I'm a developer on this feature so I can help you debug if you are still seeing the wrong env launched.
I had the same situation as the OP. After reviewing #IanHuff's answer, that if desired (target) environment does not have Jupyter installed, the Python Interactive window will use another where it is found. I considered installing Jupyter in my target environment, but it would have installed a lot of packages. Having to do that for each virtual environment would be unnecessarily burdensome. So instead of the entire Jupyter package, I installed just the ipython_kernel in the target environment as follows and it worked:
$ ipython kernel install --user --name=<target_environment_name>
Hope this helps others trying to use Visual Studio Code with Jupyter Notebooks.

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.

Categories

Resources