How can I open jupyter notebook in venv to my drake work correct - jupyter-notebook

I install drake via pip in venv and I want open files from course underactuated.
I start venv by typing:
source env/bin/activate
Drake installed correct because of output of python3 -c 'import pydrake.all; print(pydrake.__file__)':
(env) dmitriy#dmitriy:~/git/underactuated$ python3 -c 'import pydrake.all; print(pydrake.__file__)'
/home/dmitriy/env/lib/python3.8/site-packages/pydrake/__init__.py
But when I try run it in Jupyter notebook with Kernel env I have:
ModuleNotFoundError Traceback (most recent call last)
Input In [1], in <cell line: 1>()
----> 1 import pydrake.all; print(pydrake.__file__)
ModuleNotFoundError: No module named 'pydrake'
How can I open jupyter notebook in venv to my drake work correct ?

This is because I have not installed jupyter / IPython in your virtualenv.
This is the solution: Running Jupyter notebook in a virtualenv: installed sklearn module not available

Related

Installed jupyter notebook without anaconda have error like "zsh: command not found: jupyter"

I installed jupyter notebook without anaconda.
(Maybe I think that I installed this with pip3 command.)
In terminal, I can't execute jupyter notebook with this command
jupyter notebook
but another command can execute notebook
python3 -m notebook
I added path in .zshrc file. but nothing changed.
Jupyter path
pip3 show jupyter | grep Location
Location: /Users/myName/Library/Python/3.9/lib/python/site-packages
In my zshrc file
export PATH=/Users/myName/Library/Python/3.9/lib/python/site-packages:$PATH
How can I use the command "jupyter notebook" in terminal?

How to enable Stata kernel in jupyter notebook

I am using MacOS and try to use Stata in the jupyter notebook. I went over the following step to do so.
First, in the terminal:
pip install stata_kernel
python -m stata_kernel.install
conda install -c conda-forge nodejs -y
jupyter labextension install jupyterlab-stata-highlight
pip install ipystata
And then in my jupyter notebook:
import ipystata
from ipystata.config import config_stata
config_stata('/Macintosh HD⁩/Applications/Stata/StataSE')
import ipystata
%%stata
display "Hello, I am printed in Stata."
But I keep getting the error message
UsageError: Line magic function %%stata not found.
I am not sure if this is path problem or something else.
Could you help me to fix the problem?

OSMnx wont open in Juypter Notebook

I downloaded osmnx via conda using the code:
conda config --prepend channels conda-forge
conda create -n ox --strict-channel-priority osmnx
This comes from the osmnx documentation: https://osmnx.readthedocs.io/en/stable/
I can see the module has downloaded because in the Anaconda Prompt I can type conda activate oxand it works. However when I go into my jupyter notebook and type
import osmnx as ox
I get the following error:
​
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-11-7e05e48535cd> in <module>
----> 1 import osmnx as ox
2
3
ModuleNotFoundError: No module named 'osmnx'
Please advise as to what I can do. Thanks
In your terminal, run:
conda config --prepend channels conda-forge
conda create -n ox --strict-channel-priority osmnx jupyterlab
conda activate ox
python -m ipykernel install --user --name ox --display-name "Python (ox)"
jupyter lab
This installs OSMnx and JupyterLab into a conda environment called ox, activates the environment, installs an ipython kernel in the environment, then launches JupyterLab.
See also
Conda environments not showing up in Jupyter Notebook
Conda environments not showing up in Jupyter Notebook
How to use Jupyter notebooks in a conda environment?
How to add conda environment to jupyter lab
Link Conda environment with Jupyter Notebook
In which conda environment is Jupyter executing?

How to install a nbextension with python and js components as a labextension

I created a nb extension following this link!. The extension works correctly when ran from:
jupyter notebook
When I ran the same extension from
jupyter lab
The extension does not work and gives me an error:
Error displaying widget: model not found
Here is the error on console:
Could not instantiate widget
(anonymous) # manager-base.js:273
09:27:26.891 default.js:127 Error: Module test_pp, semver range 1.2.0 is not registered as a widget module
at WidgetManager.loadClass (manager.js:251)
test_pp is the extension module I am trying to run.
Following are the commands that make the extension work in notebok:
python setup.py build
pip install -e .
jupyter nbextension install --py test_pp
jupyter nbextension enable --py test_pp
jupyter notebook
Folder structure of notebook extension:
test_pp
js
lib
embed.js
extension.js
index.js
labplugin.js
test_pp.js <------ The javascript part of extension
node_modules
package.json
webpack.config.js
test_pp
static
__init__.py
_version.py
test_pp.py <-------- The extension server side python
Looking thru several tutorials and blogs I found some commands that I could run that should make it but, but they did not help:
pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension
jupyter labextension install #jupyter-widgets/jupyterlab-manager
cd jupyter_lab_src/test_pp
jupyter labextension install . <----- Fails, not a valid npm package
cd js <----- as that folder has package.json
jupyter labextension install . <---- installs successfully
jupyter lab
Open a notebook from lab, call the same commands that work in jupyter notebook:
from test_pp import test_pp
pp = test_pp.PostProcessor()
pp.initWidget()
data = 1
pp.set_data(data)
pp
Gives the error I described above. Ran a command to see the extensions:
(base) C:\data\OnScale_Jupyter\jupyterlab\test_pp>jupyter labextension list
JupyterLab v1.1.3
Known labextensions:
app dir: c:\users\anils\miniconda3\share\jupyter\lab
#jupyter-widgets/jupyterlab-manager v1.0.2 enabled ok
test_pp v0.1.0 enabled ok* <----- why is there a star
local extensions:
test_pp: C:\data\OnScale_Jupyter\jupyterlab\test_pp\js
I see an error on the conda command console as well:
[W 10:22:31.781 LabApp] Failed to fetch package metadata for 'test_pp': <HTTPError 404: 'Not Found'>
I believe, in essence, I am unsure of how to launch a nbextension as a labextension?
Any help would be appreciated?
Previously, I had the same issue. Here is what I did.
First, I installed the nbextension using the command in conda prompt.
(https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/install.html)
Then I enabled hinterland in nbextension in jupyternotebook. But still, it doesn't work in jupyter lab.
Then I followed instructions mentioned in this link:
https://jupyterlab.readthedocs.io/en/stable/user/extensions.html#id14
installed nodejs using the below command:
conda install -c conda-forge nodejs
Then I rebuild my jupyterlab using the command:
jupyter lab build
Then I could see docstring and other autofill extension working in jupyterlab, as in this image.

Jupyter: jupyter-notebook can not import module statsmodels

I have installed jupyter notebook in MacOS 10.9 Mavericks, using command
pip3 install jupyter
I can import some libraries like numpy, pandas and run Jupiter notebook normally, however, if I import the module statsmodels, it says No Module named "statsmodels'.
How can we run the installed library statsmodels in jupyter-notebook?
I had the same problem.
That's because the module has been install for python2 and not for python3 that you are using as well.
Find your python3 bin related to jupyter.
$jupyter --paths
Mine was at /usr/local/Cellar/python3/3.5.2_3/bin
run :
$python3 -mpip install statsmodels
cheers

Resources