When I use python command, I can import library (boost.python) from code if .so files are stored in the same folder as .py script. How I can do this with anaconda and Jupyter Notebook?
Anaconda has a shell interface called “Anaconda Prompt”
inside the prompt, just use the following command:
conda install <yourPackageName>
and it will be available for your jupyter notebook
https://francescolelli.info/python/install-anaconda-and-import-libraries-into-the-ide/
Related
I pip installed the sportsreference package in my command prompt and it shows successful. Yet when I try to call it in my Jupyter Notebook it says no module named sportsreference.
Any help on what I'm doing wrong?
The interpreter that your Jupyter uses to run the cells is not the one you installed that package into. Remember you can have not only different versions of Python interpreter, but also different virtual environments associated with each Python interpreter in your machine.
So either install the package in the interpreter that Jupyter uses, or run the Jupyter from the interpreter you've installed that package into.
The simplest solution is to install it in a Jupyter cell with:
!pip install <your_package_name>
the ! allows you to execute command.
To check which interpreter currently runs your code you can check the output of:
import sys
print(sys.executable)
I cannot use arcgis package in Jupyter notebook in browser.
I created a virtual environment in Conda, myenv38:
I used Conda install to install arcgis package, so it is in the virtual environment.
However, when I launch Jupyter Notebook from this environment, and select myenv38 as a kernel, arcgis returns ModuleNotFoundError: No module named 'arcgis'.
When I use import sys sys.executable in the iPynb file of the question, it shows a different path ('/Users/myname/.pyenv/versions/3.9.0/bin/python'). This is apparently weird because the virtual environment is configured with python 3.8 to make it compatible with the arcgis.
This doesn't happen in VScode, but I can't use it because the map doesn't show in it.
Do you have any suggestions?
I create a Conda environment (23OCT20A) and attach a Jupyter notebook to it. From the command line I install packages but Jupyter can't see them. It appears the Jupyter Notebook uses a different Python executable than the Conda command line environment.
How do I fix this?
From the command line the Conda environment looks to be using the correct Python: ('C:\Users\myUser\Miniconda3\envs\23OCT20A\python.exe')
From within Jupyter the Conda environment is different: ('C:\Users\myUser\Miniconda3\python.exe')
Here is how I check the Python version in each environment:
import sys
print (sys.executable)
I installed Jupyter Notebook using pip install notebook but I am not able to run it.
When I try runing using jupyter notebook, it gives me the CommandNotFoundException:
and
When I try runing using python -m notebook, it gives me the ImportError: cannot import name 'constants' from partially initialized module 'zmq.backend.cython':
I have added the following into PATH:
Path to python.exe present inside local folder.
Path to scripts folder present inside local folder.
Path to scripts folder present inside roaming folder.
All the jupyter dependencies(jupyter.exe, jupyter-core.exe, etc) are present in scripts folder inside 'Roaming' folder and not inside 'local' folder.
python version: 3.8.4
pip version: 20.1.1
Use: python3 -m notebook in the terminal.
I had worked with Jupyter Notebook and usually the cause for most of the cases is missing dependecy - Jupyter got a lot of them.
Please check if they are not missing by running:
python -m pip check
or
pip check
This will give you list of missed (sometimes there are versions problems) dependencies. Installing proper version with pip install <dep>==<version> should help.
Edited:
#Divyessh Maheshwari, if you have installed anaconda, then make sure you are running jupyter notebook in the anaconda prompt.
If you haven't and you don't want to install anaconda, you might need to downgrade Python according to this answer Is there a way to run Jupyter Notebooks Without Anaconda?
How to open an .ipynb file on a Mac and use it?
Which apps is needed for that or what are your recommendations?
you need to install jupyter you can do it using: pip install jupyter
and run it in terminal with the command jupyter notebook this will open a browser window where you can view and run juputer notebooks
You can also open these notebooks in pyCharm and Visual Studio Code (after installing the python extension from microsoft)
You tagged this with visual-studio-code so I'm answering in the context of Visual Studio Code.
VS Code has support for creating, opening/viewing, and running Jupyter notebooks (.ipynb files). Check out their complete tutorial from the VS Code docs: Working with Jupyter Notebooks in Visual Studio Code.
Visual Studio Code supports working with Jupyter Notebooks natively,
as well as through Python code files. This topic covers the native
support available for Jupyter Notebooks and demonstrates how to:
Create, open, and save Jupyter Notebooks
Work with Jupyter code cells
View, inspect, and filter variables using the Variable explorer and Data viewer
Connect to a remote Jupyter server
Debug a Jupyter notebook
If you just want to view/open a .ipynb file, just open it in VS Code like any other file.
If it doesn't open like that and you get a "weird" JSON-like file, make sure the setting "Jupyter: Use Notebook Editor" is enabled.
"jupyter.useNotebookEditor": true
If you need to be running cells, you'll need to setup your environment and install the Jupyter package.
You can let VS Code do all the initial setup steps for you. Open or create a .ipynb file, and try to run any cell. If your environment is not yet setup, it will show an error:
So click on that Install button to let VS Code install all the dependencies on the currently selected Python environment.
Or if you want to install it yourself, select and activate an environment, then:
$ pip install jupyter
Once the Jupyter package is now installed, you'll see that the "Jupyter Server" indicator at the top right is now activate. Now, you can run cells.
So basically, all you need to do is:
Install VS Code
Setup a Python environment
On mac OS, it already has Python 2 but I recommend not using that
Instead, I recommend installing Python 3 via Homebrew
Install the Jupyter package
Select the Python environment (with the Jupyter package)
Open and edit .ipynb files
To quickly view an .ipynb file you can use the nbviewer-app.
Installation via Homebrew:
$ brew install --cask jupyter-notebook-viewer
Alternatively, you can also download the app directly.
Starting with Mac OS Catalina, you might have to open a terminal and run
xattr -d com.apple.quarantine /Applications/Jupyter\ Notebook\ Viewer.app
after installation because the app is not notarized by Apple [Source].