I cannot use jupyter notebooks in pycharm - python

I am using pycharm with a virtual environment set in preferences. That environment has installed python 2.7.13. I have installed anaconda in the virtual environment, which contains jupyter. I had the professional version but have allowed the subscription to lapse.
According to https://www.jetbrains.com/help/pycharm/2016.3/using-ipython-jupyter-notebook-with-pycharm.html I can create a notebook by opening the project window and using command-N, When I do this, I CAN select jupiter notebook but there is no way to enter the filename that they require.
Trying it another way, I use File->New->Python File and, for the name use test.ipynb. Pycharm accepts it but puts on a '.py' suffix, treating it as a normal python code file: test.ipynb.py.
Any ideas on how I get this to work?

I think u should try File->New->Jupyter Notebook, this works for me.

Related

Jupyter in VSCode

enter image description here
At first, jupyter notebook works fine. BUT, whenever I try to use the other ipynb file, jupyter notebook does not work and send this message. How should I deal with this?
Have you checked which python interpreter you are using in the Jupyter Notebook?
With the different names of the .ipynb file, it will take the different kernels, and it is stored in the database.
First of all, create a virtualenv. Open the terminal using Ctrl+Shift+`.
In the console, type python3 -m venv venv.
This will create a folder named venv in your working directory.
Now, in the bottom left corner, you will find the selected python interpreter. Click that and change it to venv.
(If windows raises permission error, In your vsCode settings, add the following lines.)
"terminal.integrated.shellArgs.windows": ["-ExecutionPolicy", "Bypass"]
Now delete all previous terminals and open a new terminal.
Install the required packages using pip and carry on.

Jupyterlabs Notebook and command line Python have different system path?

Question:
What's the best way to set a Jupyterlab's notebook to have the same sys.path as Python when it's run from the Mac terminal?
Background:
I can use a python module (Beautiful Soup) successfully by starting Python from the Mac terminal (within a virtual environment named VENV). It installs, imports and works fine. But the Jupyterlabs notebook using the same VENV environment, won't import the very same module. I confirmed they are both using the same Python instance using the "Which Python" command, but terminal and notebook have a different sys.path, which appears to be restricting what the notebook can see.
What's the best way to handle this path inconsistency?
I found a workaround to make it work.
Thanks to Peter Bakke.
https://www.peterbakke.com/data-analysis/set-system-path-python-jupyter-notebooks/
I also installed BeautifulSoup4, rather than bs4.

VS Code: Can't load anaconda environment on Python Interactive

I am using VS Code in Windows 10.
I am able to use the dependencies in my conda environment if I Run the Python Script in Terminal. However, I am not able to use the environment in the Python Interactive shell.
For instance, I am using my datascienceenvironment which has the package fuzzywuzzy. I have included the env path into the settings.jsonas the python.pythonPath. But the Python version used in the Jupyter Notebook is the default anaconda base C:\\ProgramData\\Anaconda3\\python.exe
What is also extrange, is that if I run !conda list within the Notebook, I can see the fuzzywuzzy package.
What am I missing?
Thanks!
I'm a developer on the Interactive Windows. Priyatham has already pointed you in the right direction. Currently our Window tries to use the currently selected environment (the one in the lower left corner). But we didn't want to totally block customers if they didn't have Jupyter installed in each environment. So if the selected interpreter doesn't have Jupyter in the environment we'll check other environments on the system, looking for the closest python version match to the currently selected one. If we find something with Jupyter we'll launch the Interactive Window using that. In this case we do show a popup in the lower right indicating that we didn't find Jupyter and that we are falling back on a different environment, but this message can be pretty easy to miss.

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