Using plot.ly in jupyterlab - graphics does not show - anaconda

I want to draw 3D PCA with pylot (Scatter3d), however the graphics is not showing up in jupyterlab only in jupyter-notebook.
I've installed the 'jupyterlab_plotly' package and I was able to create an 'jupyterlab_plotly.Plotly object', but I couldn't figure out how to actually include/draw the graphics in the notebook.
I wonder if someone could post a working example of drawing figures in jupyterlab with pyplot.
(The example at the project's git site - https://github.com/gnestor/jupyterlab_plotly- only present an 'jupyterlab_plotly.Plotly object', but not the graphics itself)
Thanks,

I had the same issue. Looks like the project has moved over here:
https://github.com/jupyterlab/jupyter-renderers
Installing with the suggested:
jupyter labextension install #jupyterlab/plotly-extension
worked for me.

This is now superseded by jupyter labextension install jupyterlab-plotly as per https://plotly.com/python/getting-started/#jupyterlab-support-python-35

The answer by #user1561393 describes a good solution.
I want to add that the plotly documentation also covers these steps in some extra detail in their 'Getting started' guide. This should normally remain up-to date even when some they migrate to newer services (as has happened with their V4).

Related

Readthedocs / Sphinx not rendering bullet list from rst file

I have a set of rst files that I am building in readthedocs with sphinx. The files have multiple bullet lists, but they are not being rendered correctly.
The text appears, but there are no bullet symbols or nesting / indentation.
To make sure it was not my files, I did a direct copy-paste from the sphinx_rtd_theme page (https://github.com/readthedocs/sphinx_rtd_theme/blob/b07560bf97dad3a4266f6145bd4b662ac708ab00/docs/demo/lists_tables.rst)
This is what the rst is supposed to render as (with ::marker for each list item in the html file)
This is what I am getting when I build the same rst using my local sphinx / rtd setup
Is there something I need to fix in my conf.py or other files?
We had the same issue (bullet points disappearing in lists) after refreshing the conda environment we use for releasing one of our packages. The other solutions listed here (thus far) didn't work for me, but downgrading docutils <0.17 did.
We are using nbsphinx (some of our docs illustrate operations with notebooks), and had recently some issues due to related package versions (jinja2, sphinx, docutils). Based on issues/comments (such as this one and that one), we used various older versions of these packages.
But as of this writing and thanks to the hard work of all the maintainers, we were able to remove all pins except for docutils. FWIW, for our current needs, the relevant subset of packages we use is:
docutils 0.16 py38_1
jinja2 3.0.0 pyhd3eb1b0_0
nbsphinx 0.8.6 pyhd8ed1ab_1 conda-forge
sphinx 4.0.1 pyhd3eb1b0_0
sphinx_rtd_theme 0.4.3 py_0
I had the same issue when using Read-The-Docs as a theme along with Sphinx-AutoAPI. Based on the answer of "Pierre D" I downgraded the docutils using:
conda install docutils=0.16
The solution worked for me. Both, missing bullets and the elongated line spacings were resolved. I guess the problem is caused by a bug in the docutils package and hope it will be fixed soon.
Other answers here point to docutils as the having the bug. But, the bug is actually in sphinx-rtd-theme. So, even though downgrading docutils seems to work, the solution that worked for us, that I think is better, is to
upgrade sphinx and sphinx-rtd-theme past the bugfix. For us, that looked like requiring sphinx>=4.3.0 and sphinx-rtd-theme>=0.5.1 (see our PR)
Seems to be a issue with sphinx_rtd_theme and new HTML5 tags in docutils. See https://github.com/readthedocs/sphinx_rtd_theme/issues/1115 for more info. As mentioned, current resolution is downgrade to docutils=0.16.
I just discovered that an RtD documentation set I maintain was experiencing this exact problem, where bullets would show on my local builds (accompanied by the ::marker in the page source) but would be absent in RtD builds (no ::marker in the page source).
I tried a couple of things that didn't work before finding this thread. Nick Crews's answer worked perfectly: I added the >=0.5.1 lower-bound constraint to the requirements-rtd.txt file that I've configured RtD to use (I already had a Sphinx==5.3.0 pin, for reasons), and poof! I had my bullets back.
UPDATE 31 Jan 2023: Based on the comments in this sphinx_rtd_theme GitHub issue, it's also important to be sure that the version of docutils that gets installed is not too high. The thread recommends a constraint of docutils<0.17, though in recent builds my bullets have rendered fine with docutils==0.17.1.
This got me curious as to why it was necessary for me to add this constraint, when I'd already had sphinx-rtd-theme declared in requirements-rtd.txt.
On taking a closer look at my RtD build logs, I discovered that RtD has its own default-requirements install step, prior to installing anything I specify in my config. In this default install step, it was installing sphinx-rtd-theme<5.0:
Collecting sphinx-rtd-theme<0.5
Downloading sphinx_rtd_theme-0.4.3-py2.py3-none-any.whl (6.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.4/6.4 MB 117.0 MB/s eta 0:00:00
Thus, when pip hit the sphinx-rtd-theme line in requirements-rtd.txt, it just ignored it, because a version of it was already installed:
Successfully installed attrs-22.1.0 importlib-metadata-5.0.0 sphinx-5.3.0
sphinx-issues-3.0.1 sphinx-removed-in-0.2.1 sphinxcontrib-applehelp-1.0.2
sphinxcontrib-devhelp-1.0.2 sphinxcontrib-htmlhelp-2.0.0 sphinxcontrib-jsmath-1.0.1
sphinxcontrib-programoutput-0.17 sphinxcontrib-qthelp-1.0.3 zipp-3.10.0
Adding the >=0.5.1 constraint thus forces an upgrade/reinstall of sphinx-rtd-theme to the latest version, fixing the problem.
So... where did this sphinx-rtd-theme<0.5 pin come from?
After digging into the RtD source for a while, I found out that there's a toggle for, essentially, "are we using the latest Sphinx version or not?":
# If defaulting to Sphinx 2+, we need to push the latest theme
# release as well. `<0.5.0` is not compatible with Sphinx 2+
self.project.get_feature_value(
Feature.USE_SPHINX_LATEST,
positive='sphinx-rtd-theme',
negative='sphinx-rtd-theme<0.5',
),
So, okaaay... I do want to use a recent version of Sphinx... why am I apparently set up to not USE_SPHINX_LATEST?
Looks like it's a compatibility decision made at some point. Any RtD docset created before a certain date (20 Oct 2020, for a personal project like mine; or, 21 Jan 2021 for RtD for Business projects) is set as not USE_SPHINX_LATEST. I assume these dates were picked for some strategic reason, likely having to do with in-the-wild usage of Sphinx < 2.0 dropping below some threshold.
Anyways! If you see a sphinx-rtd-theme<0.5 and/or sphinx<2 constraint in your RtD build logs, that's why. And, again, follow Nick Crews's advice to fix it.
I had the same problem, when listing using *, in the .rst file like:
* first item
* second item
I found out that the problem, in my case, was that I was using the theme sphinx_rtd_theme, but I didn't add it in extensions in the conf.py file. So adding the following worked for me:
extensions = [sphinx_rtd_theme,
# other extensions
]
Creating a new sphinx project solved the problem
Had the same problem:
Creating new sphinx-quickstart didn't work.
Reducing docutils to 0.16 and adding 'sphinx_rtd_theme' to the extensions list in conf.py worked:
extensions = ['sphinx_rtd_theme']

How to install CouchDB on Windows

This might seem like a basic question, but let me explain.
I'm currently trying to get CouchDB running on Windows. Usually (from what I can tell watching several YT tutorials) you just go to couchdb.apache.org/download and download the windowsx64 version. Then open it and a install wizard should appear.
However when I download the file I get a file named "fd15d91c1e214c3451bef296564086f6a9266e848d57eaa8ac596e3765939578" which isn't openable and doesn't give me a wizard.
Is the current CouchDB installation corrupted? Am I doing something wrong?
I just tried http://couchdb.apache.org/, chose the Download link from the top navigation bar, then Windows(x64) for version 2.1.0. This kicked-off downloading the file apache-couchdb-2.1.0.msi.
Definitely try another browser or restart your machine.

Scientific Python installation recommendations

I am new to Python and starting work on a large project that will be distributed to users. I am also the first in my company to be using, and I wanted to get recommendations on the best way to install Python & packages, so that I don't head off in the wrong direction.
I require data analysis frameworks (pandas, numpy, scipy, matplotlib, statsmodels, pymongo) and my initial approach was to install Python 3.5 directly, and then use pip install on each package.
I ran into similar problems that others have found [Unable to find vcvarsall], and resolved. Next problem was with BLAS and LAPACK missing when installing scipy. At this point I decided Anaconda was the way to go, rather than individual pip installs, and was easily able to set everything up.
One problem with Anaconda is that it installs a lot of packages which I will never use, and may not have some which I would like to use in future, e.g. TensorFlow (presumably can do pip install to get extra ones that are not included?).
An in-between solution seems to be Miniconda, which I believe would have fixed the BLAS/LAPACK problem with scipy.
So my question is: can someone with experience of developing data analysis projects in Python, that will be deployed to users' Windows desktops, and with server-side components running on Linux, provide recommendation of what they would do if starting from scratch at new organization?
(I'm currently in favour of heading down the Anaconda route.)
Personally, I think Anaconda(conda) is better. First of all, conda is cross-platform package manager, and it is easy to install and use. Second, conda has functionality of virtualenv, and you can use conda create to create environment. Finally, there is Anaconda cloud and condo-forge, those community can help you solve conda issue, build packages, and share ideas.
Moreover, Anaconda(conda) indeed install a lot of packages, but those are all dependencies. For example, when you "conda install scikit-learn", conda will automatically help you install the dependency, numpy and spicy.

OpenMDAO: First Steps

I am new in the world of OpenMDAO (and also on Python) and I am having some problems to understand the use of the software. I have already installed Anaconda (pyth v2.7) and the OpenMDAO, but I don't know how to run it. I am following this tutorial but I am not sure if I am doing it properly. I write the .py files in notepad++, and I try to run on the IPython but when I use the command : from paraboloid import Paraboloid it appears an error : No module named.api. I think that maybe I am not using the correct path (I'm in the folder where I have the .py files). Probably it's an stupid error, so sorry for the question.
Thank you all, Jose M O
If your tutorial link above is correct, I see that you are using a tutorial for OpenMDAO 0.1.0. That version is 5.5 years old at this time, and is no longer supported. We will be happy to help with your questions, but to get a better foundation, and a much more useful tool, please consider:
Install OpenMDAO 1.5.0 (pip install openmdao or read these installation docs)
Try this paraboloid tutorial instead.
Good luck,
Keith
NOTE: If you installed OpenMDAO 1.x.x and are using the tutorial from 0.1.0, you would have many problems with api imports, as many things have changed since 0.1.0.

Totally Lost on "Installing" OpenCV / ctypes-opencv for Python 3

edit: The real solution to this is now that OpenCV supports python 3. I'm leaving the details below for anyone who happens to be stuck with an old setup.
I'm trying to get OpenCV working with Python 3. A friend showed me ctypes-opencv that appears to work with Python 3. The problem is I totally can not figure out how to "install" or get any code working. I've followed all instructions I could find from a few people mentioning installs on google and none of those seemed to work or I couldn't even get through the basics that they mentioned.
I am just hacking around with the version of IDLE that came with Python 3. No IDE.
Start with OpenCV:
The only windows installer for OpenCV 2.1 is a visual studio installer. I assume that means that it installs files that make it easier to use in Visual Studio. However, does it also mean that I can't use that installer with Python 3? I tried the vs installer together with ctypes-opencv as below, and I got errors that the dlls were not in my path (but my path variable did include the OpenCV bin folder with dlls). Is this the wrong direction?
The apparent alternative is to build OpenCV myself. I tried following the directions here and all I get is "project files may be invalid" from the CMake gui application when pressing the "Configure" button. Same when following these hints from Stack Overflow. I'm suspicious that this is also the wrong direction since I am not currently using any of the tools that are listed in the CMake configure. Is this also the wrong direction?
Next ctypes-opencv:
I installed this and the installer recognizes Python3.1 and puts itself into the site-packages folder. If I try to run demos, it tells me the dlls are not in the path although they are, as mentioned above.
Summary:
I think I generally understand each piece here (code, compile, dll, imports, ...) but I do not know how all the pieces fit together and where I am going wrong. Can someone please tell me what steps or understanding I am missing here?
I get the feeling that I need to be reading a book or two to fill in the holes in my understanding of how all these pieces fit together. I wouldn't even know what area of books to get though so any suggestions there would be appreciated as well.
Python's ctypes is a wrapper around the opencv dll files, as long as you can point to the compiled libraries it doesn't matter what the source code is set up to be edited in. For windows I would simply run the installer, then try to load the dll with ctypes. If you can get that far, any other errors can be fixed by looking at the ctypes wrapper file and editing the load section to look like your test file.
Christoph Gohlke maintains Windows binaries for many Python packages, including the production version of OpenCV 3.0 with Python 3.x bindings, released 4 June 2015:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv
To install, just download the 64-bit or 32-bit .whl file appropriate for your system, then run pip install [filename]. Then the instruction import cv2 should work in your Python 3.x interpreter.
Yakiimo san, OpenCV 2.1 DLL can be loaded with ctypes. I have tested it.
p.s. I have set the C;\OpenCV2.1\bin in Env Path.

Resources