I'm trying to install jupyter-matplotlib extension but can't make it work in a jupyterlab instance.
Once installed by following the steps here:
https://github.com/matplotlib/jupyter-matplotlib
I get the error when executing a simple example:
Error displaying widget: model not found
Here's the output of my $ conda list for relevant packages:
ipykernel 5.1.1
ipympl 0.2.1
ipython 7.6.1
ipython_genutils 0.2.0
ipywidgets 7.5.0
jupyter_client 5.3.1
jupyter_core 4.4.0
jupyterlab 1.0.2
jupyterlab_server 1.0.0
Solved!
Turned out ipywidget 7.5 breaks jupyter lab and it isaffecting other libraries too.
https://github.com/plotly/plotly.py/issues/1659
downgrading to 7 solved the issue for me (allthough 7 wrt 7.5 should be backward compatibile)!
Also be sure to match ipympl 0.2.1 with jupyter-matplotlib 0.3.0 labextension.
jupyter labextension install jupyter-matplotlib#0.3.0
First you need to install:
pip install ipywidgets
conda install -c conda-forge ipympl
Then check if the following is OK:
!jupyter labextension list
You should see something like this:
JupyterLab v3.0.14
/home/jovyan/.local/share/jupyter/labextensions
jupyter-leaflet v0.15.0 enabled OK
jupyterlab-plotly v5.1.0 enabled OK
#jupyter-widgets/jupyterlab-manager v3.0.0 enabled OK (python, jupyterlab_widgets)
The most important part is here:
Restart your jupyter notebook.
Related
I am trying to create and run a jupyter notebook (jupyter notebook --port xxxx) in the directory of a project I am working on to do some debugging. When I try to run it the notebook fails to connect to a kernel with the following error returned by the server repeatedly:
[I 17:29:24.011 NotebookApp] KernelRestarter: restarting kernel (5/5), new random ports
2022-01-28 17:29:24.789877: I tensorflow/stream_executor/platform/default/dso_loader.cc:49]
Successfully opened dynamic library libcudart.so.11.0
usage: ipykernel_launcher.py [-h] --config CONFIG [--results_dir RESULTS_DIR]
ipykernel_launcher.py: error: the following arguments are required: --config
This is an empty notebook where I am trying to execute the first cell, it happens irrespective of the code that this cell contains. On top of that I CAN RUN A NOTEBOOK IN ANY OTHER DIRECTORY FROM THE SAME SERVER which makes this extra strange!
It seems that jupyter implicitly runs some code during kernel start that reads whatever is in my project directory out of context and inevitably fails to run it. I want to run it in that very directory to test the module I am working on.
I tried deleting .ipynb_checkpoints, restarting the server and recreating the notebook from scratch, but that didn't help.
Here is a selected pip list of the modules I have installed in my conda environment. Python version == 3.7.0
Package Version
----------------------- ---------
importlib-metadata 4.10.1
importlib-resources 5.4.0
ipykernel 6.7.0
ipython 7.31.1
ipython-genutils 0.2.0
ipywidgets 7.6.5
jupyter 1.0.0
jupyter-client 7.1.2
jupyter-console 6.4.0
jupyter-core 4.9.1
jupyterlab-pygments 0.1.2
jupyterlab-widgets 1.0.2
Keras-Preprocessing 1.1.2
matplotlib 3.5.1
matplotlib-inline 0.1.3
nbclient 0.5.10
nbconvert 6.4.1
nbformat 5.1.3
notebook 6.4.8
numpy 1.19.5
pandas 1.1.5
scipy 1.7.3
tensorboard 2.8.0
tensorboard-data-server 0.6.1
tensorboard-plugin-wit 1.8.1
tensorflow-estimator 2.4.0
tensorflow-gpu 2.4.0
typing 3.7.4.3
typing_extensions 4.0.1
Edit: This file is contained in the same directory as the notebook I am trying to run:
import argparse
from myModule.training import main
parser = argparse.ArgumentParser()
parser.add_argument('--config', type=str, required=True)
parser.add_argument('--results_dir', type=str, default='results_training')
args = parser.parse_args()
config = args.config
results_dir = args.results_dir
hist = main(config, results_dir)
I am using tqdm to display progress of iterations. However it doesn't work properly in my jupyter notebook environment.
I can do
from tqdm import tqdm
a = 0
for i in tqdm(range(10)):
a += i
print(a)
with output
This however has a problem with print statements in the loop (see here).
When I do
from tqdm.notebook import tqdm
a = 0
for i in tqdm(range(10)):
a += i
print(a)
I get
I.e. the iterations are executed but tqdm does not account for them.
Any idea how to fix this or what the problem might be?
The output of jupyter --version is
jupyter core : 4.7.1
jupyter-notebook : 6.2.0
qtconsole : not installed
ipython : 7.20.0
ipykernel : 5.1.0
jupyter client : 6.1.11
jupyter lab : not installed
nbconvert : 5.6.1
ipywidgets : 7.6.3
nbformat : 5.1.2
traitlets : 5.0.5
EDIT
The problem seems to be bound to MacOS (I am running 10.15.7), since I do not observe it on CentOS.
Besides that I tried I updated my conda environment
jupyter core : 4.7.1
jupyter-notebook : 6.2.0
qtconsole : 5.0.2
ipython : 7.20.0
ipykernel : 5.5.0
jupyter client : 6.1.11
jupyter lab : not installed
nbconvert : 6.0.7
ipywidgets : 7.6.3
nbformat : 5.1.2
traitlets : 5.0.5
on python 3.8.8. (I also tried on 3.7.10).
This issue discusses something similar and the problems seems to be related to ipywidgets.
I had the same issue in Jupyter Lab (3.0.9) and this worked for me:
jupyter labextension install #jupyter-widgets/jupyterlab-manager \
&& jupyter lab
Even though ipywidgets should install the labextension automatically, it was not listed in jupyter labextension list. When I install it manually, the progress bar works.
For classic notebooks, the ipywidgets docs mention this:
jupyter nbextension enable --py widgetsnbextension
I'm stumped. I'm developing some enhancements to scikit-image which are failing the automated build tests, probably due to rounding errors. I therefore need to get the automated tests running on my Windows system so that I can debug and work out what's wrong. I've so far tried two approaches, neither of which are working:
In my Anaconda Python 3.6 environment, when I try to run the automated tests, I am getting the following error:
RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb
...which I have found reference to in other contexts, but have not been able to eliminate.
Since the automated test do run (but fail) on a Python 3.5-based system, I thought things might work if I tried a local Python 3.5 environment. Here, I am running into the issue that, despite being installed, the environment cannot find the MS C++ compiler cl.exe. It is installed in C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\bin\HostX86\x64\ and is found and executed by my Python 3.6 environment, but my Python 3.5 environment doesn't find it despite me adding that directory to my PATH. I should add that my Python 3.6 environment finds it without the directory being added to the PATH. I understand that both Python 3.5 and 3.6 use MSVC 14.0.
I would prefer to fix the problem in my Python 3.6 environment if possible. Any assistance much appreciated.
Update
I have made a box-fresh Python 3.6 conda environment as follows:
conda create --name sk36 python=3.6
conda activate sk36
conda install scikit-image --only-deps
conda install cython
git clone https://github.com/scikit-image/scikit-image.git
cd scikit-image
pip install -e .
pytest skimage/feature
The specific error I am getting is as follows:
..\Anaconda3\lib\site-packages\py\_path\local.py:662: in pyimport
__import__(modname)
skimage\__init__.py:135: in <module>
from .data import data_dir
skimage\data\__init__.py:13: in <module>
from ..io import imread, use_plugin
skimage\io\__init__.py:7: in <module>
from .manage_plugins import *
skimage\io\manage_plugins.py:24: in <module>
from .collection import imread_collection_wrapper
skimage\io\collection.py:12: in <module>
from ..external.tifffile import TiffFile
skimage\external\tifffile\__init__.py:1: in <module>
from .tifffile import imsave, imread, imshow, TiffFile, TiffWriter, TiffSequence
skimage\external\tifffile\tifffile.py:292: in <module>
from . import _tifffile
E RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb
...which appears to have something to do with tifffile. Since this package wasn't originally explicitly installed in my new environment, I tried installing various versions of it, including some which downgraded numpy and scipy. Still the same error as above.
Having done some more research it would appear that something is seeing numpy 1.13.x when in fact version 1.15.4 is installed. Here is the full output from conda list:
# Name Version Build Channel
blas 1.0 mkl anaconda
ca-certificates 2018.03.07 0 anaconda
certifi 2018.10.15 py36_0 anaconda
cloudpickle 0.6.1 py36_0 anaconda
cycler 0.10.0 py36h009560c_0 anaconda
cython 0.29 py36ha925a31_0 anaconda
dask-core 0.20.0 py36_0 anaconda
decorator 4.3.0 py36_0 anaconda
freetype 2.9.1 ha9979f8_1 anaconda
icc_rt 2017.0.4 h97af966_0 anaconda
icu 58.2 ha66f8fd_1 anaconda
imageio 2.4.1 py36_0 anaconda
intel-openmp 2019.0 118 anaconda
jpeg 9b hb83a4c4_2 anaconda
kiwisolver 1.0.1 py36h6538335_0 anaconda
libpng 1.6.35 h2a8f88b_0 anaconda
libtiff 4.0.9 h36446d0_2 anaconda
matplotlib 3.0.1 py36hc8f65d3_0 anaconda
mkl 2019.0 118 anaconda
mkl_fft 1.0.6 py36hdbbee80_0 anaconda
mkl_random 1.0.1 py36h77b88f5_1 anaconda
networkx 2.2 py36_1 anaconda
numpy 1.15.4 py36ha559c80_0 anaconda
numpy-base 1.15.4 py36h8128ebf_0 anaconda
olefile 0.46 py36_0 anaconda
openssl 1.0.2p hfa6e2cd_0 anaconda
package_has_been_revoked 1.0 0 enable_revoked
pillow 5.3.0 py36hdc69c19_0 anaconda
pip 18.1 py36_0 anaconda
pyparsing 2.3.0 py36_0 anaconda
pyqt 5.9.2 py36h6538335_2 anaconda
python 3.6.7 h33f27b4_1 anaconda
python-dateutil 2.7.5 py36_0 anaconda
pytz 2018.7 py36_0 anaconda
pywavelets 1.0.1 py36h8c2d366_0 anaconda
qt 5.9.6 vc14h1e9a669_2 anaconda
scikit-image 0.15.dev0 <pip>
scipy 1.1.0 py36h4f6bf74_1 anaconda
setuptools 40.5.0 py36_0 anaconda
sip 4.19.8 py36h6538335_0 anaconda
six 1.11.0 py36_1 anaconda
sqlite 3.25.2 hfa6e2cd_0 anaconda
tifffile 0.15.1 py36h452e1ab_1001 conda-forge
tk 8.6.8 hfa6e2cd_0 anaconda
toolz 0.9.0 py36_0 anaconda
tornado 5.1.1 py36hfa6e2cd_0 anaconda
vc 14.1 h21ff451_3 anaconda
vs2015_runtime 15.5.2 3 anaconda
wheel 0.32.2 py36_0 anaconda
wincertstore 0.2 py36h7fe50ca_0 anaconda
zlib 1.2.11 h8395fce_2 anaconda
Update 2
I've solved the problem for Python 3.6, and I think there's enough information above for the astute to be able to work out what was wrong. I'll put the solution in an answer below.
A cleanly built Python 3.5 environment can't find the compiler, so that issue still remains.
One approach you could try is to upgrade your numpy with
pip install numpy --upgrade
as described here: RuntimeError: module compiled against API version a but this version of numpy is 9
Otherwise (if for some reason you cannot upgrade numpy) I would suggest going with a virtual environment for scikit-image project. I just tried it on Windows 10 and was able to successfully execute tests. My steps (from cmd, inside the project folder):
conda uninstall scikit-image to remove any previously built/installed versions
conda -n scikit-image python=3.6 to create a virtual environment for this project (I used python 3.6, but you can change it to 3.5)
activate scikit-image activated the new virtual env
pip install -r requirements.txt -- installed dependencies (without this step I wasn't getting the dependencies for tests installed)
pip install -e .
pytest
It turns out that pytest wasn't actually installed in the correct environment, it was being invoked from base which did indeed have numpy 1.13.3 installed. Installing it in the cleanly built Python 3.6 environment solved the problem for Python 3.6 at least.
I updated my Jupyter Notebook and it does not create a new notebook under the current directory as it used to. Instead, it always creates a new notebook under the start-up directory.This happens on my Mac and Windows computers. How can I fix this?
1) Creating a new notebook under project1
2) A new notebook was successfully created
3) However, this notebook was created under the jupyter start-up directory rather than project1
Jupyter did not behave like this before. Is this a bug or intended behavior?
Here are my Jupyter related package versions.
# Name Version Build Channel
jupyter 1.0.0 py36h598a6cc_0
jupyter_client 5.2.2 py36_0
jupyter_console 5.2.0 py36hccf5b1c_1
jupyter_contrib_core 0.3.3 py36_1 conda-forge
jupyter_contrib_nbextensions 0.3.3 py36_0 conda-forge
jupyter_core 4.4.0 py36h79cf704_0
jupyter_highlight_selected_word 0.1.0 py36_0 conda-forge
jupyter_latex_envs 1.4.0 py36_1 conda-forge
jupyter_nbextensions_configurator 0.4.0 py36_0 conda-forge
jupyterlab 0.27.0 py36hd3092eb_2
jupyterlab_launcher 0.4.0 py36h93e02e9_0
notebook 5.3.1 py36_1
Per ilyas's advice, updated my notebook to 5.4.0 and this issue was resolved.
Solution: Run
conda update conda
And then:
conda update --all
in your anaconda prompt. There are recent updates to jupyter that will fix this issue.
I'm new to Python and recently installed PyCharm 2016.3 on Windows 10. I'm also using Anaconda 3.
I don't know much about package management and would like to understand it better. Normally I just use conda update --all but I noticed (by checking the package list of my local PyCharm Interpreter) that this doesn't upgrade all packages to the latest version.
One such package is Pillow of which there's a version 4.0.0 but conda (4.3.11) won't update it past 3.4.2. I tried conda install pillow: 4.0.0 and got:
UnsatisfiableError: The following specifications were found to be in conflict:
- pillow 4.0.0*
- python 3.5*
- spyder-app
Use "conda info <package>" to see the dependencies for each package.
Later I found out that Pillow is also available on conda-forge so I tried conda install -c conda-forge pillow=4.0.0 and got:
The following NEW packages will be INSTALLED:
libiconv: 1.14-vc14_4 conda-forge [vc14]
libxml2: 2.9.3-vc14_9 conda-forge [vc14]
olefile: 0.44-py35_0 conda-forge
vc: 14-0 conda-forge
The following packages will be UPDATED:
freetype: 2.5.5-vc14_2 [vc14] --> 2.7-vc14_0 conda-forge [vc14]
jpeg: 8d-vc14_2 [vc14] --> 9b-vc14_0 conda-forge [vc14]
libtiff: 4.0.6-vc14_2 [vc14] --> 4.0.6-vc14_7 conda-forge [vc14]
pillow: 3.4.2-py35_0 --> 4.0.0-py35_2 conda-forge
The following packages will be SUPERCEDED by a higher-priority channel:
conda: 4.3.11-py35_0 --> 4.2.13-py35_0 conda-forge
conda-env: 2.6.0-0 --> 2.6.0-0 conda-forge
qt: 4.8.7-vc14_9 [vc14] --> 4.8.7-vc14_6 conda-forge [vc14]
I decided not to proceed and instead tried pip install pillow. Since this command doesn't ask for confirmation the package was simply installed. Now when I type conda list I get:
Pillow 4.0.0 <pip>
pillow 3.4.2 py35_0
The package list of the PyCharm Interpreter now shows Pillow as being version 4.0.0 but conda update pillow still returns:
# All requested packages already installed.
pillow 3.4.2 py35_0
My questions are:
1) What should I rely on to keep all my packages up to date, without compatibility issues?
2) Why did conda install pillow: 4.0.0 return an error but conda install -c conda-forge pillow=4.0.0 didn't?
3) What do the * next to pillow 4.0.0 and python 3.5 in the list of dependencies mean?
4) Since now I have both Pillow 3.4.2 (in /anaconda3/pkgs) and Pillow 4.0.0 (in /anaconda3/lib/site-packages) which one would be used if I imported Pillow?
5) Does the superseding conda: 4.3.11-py35_0 --> 4.2.13-py35_0 conda-forge mean conda is getting downgraded?
6) What is the difference between the tags pip, py35_0, py35_4, np111py35_2, etc?
7) PyCharm tells me there's a version 2.9.5 of package Jinja2 but both normal conda and conda-forge only find 2.9.4. From which channel is PyCharm getting this information?
Ok, I can't answer all of your questions but here goes:
1) Conda defers to the "pain up front" approach for handling dependency/conflict resolution. You'll have to get all of your packages to play nicely together in the repo's/channels that you have available to even make a package or keep them in an environment together. You can try running it with --force or --no-deps to try getting it in but ..... that can cause issues for you in the future (I don't know if that would even work with the later versions of conda, it changes a lot). Simply keeping packages up to date, and up to latest, I would just use pip. Its come a long way in the last few years (https://glyph.twistedmatrix.com/2016/08/python-packaging.html)
2) I am not completely sure, I believe it would have something to do with providing an explicit non-url channel for conda to look at. Typically you pass it the URL to the conda-forge repo (I think, again we don't use conda-forge internally).
3) The * means you are ignoring the patch/build 4.0.0 == Major.Minor.Build. Likewise, 3.5* == any version of 3.5
4) I would import pillow in a terminal, and then print out the module to see where its getting pulled from, why guess?
5) pass (although I think so)
6)
pip : means you installed that package via pip. It will not be picked up if you do conda list --explicit
py35_0 : has a requirement / only available to envs / packages that use python 3.5
py35_4 : not sure (always forget that one)
np111py35_2 : requires python3.5 and also numpy 1.11 (I think *)
7) I tend to steer clear of pycharm, I believe that you can inspect the python interpreter that pycharm is pointing at to see what environment its in. Based on the root environment, you can do a conda info and get a list of all of the channels you are pointing to.
Note: if you are going to use conda, you may just want to add conda-forge to your channels list instead of passing the -c (but seeing how the other channels are organized should help you see how you should pass the -c flag)