JupyterLab print markup and outputs only - jupyter-lab

Perhaps this is too obvious but I can't find a way to do it: how can I print a JupyterLab notebook without the code? I only want to show markup cells and outputs.

With my thanks to Krassowski for pointing me in the right direction. The answer is to use nbconvert from the command line thus:
jupyter nbconvert --to html your-file-name.ipynb --no-input
And this generates your-file-name.html
For me, it didn't work the first time around. I got this error:
$ jupyter nbconvert --to html testfile.ipynb --no-input
[NbConvertApp] Converting notebook oppo.ipynb to html
Traceback (most recent call last):
[...]
AttributeError: module 'jinja2' has no attribute 'Markup'
If that happens to you, try this:
pip install --upgrade nbconvert
[...]
Successfully installed mistune-2.0.4 nbconvert-7.2.3 tinycss2-1.2.1
This worked for me. It case it helps, I am on jinja2 3.1.2.

Related

How can I resolve python requests package import error?

I am new to python and am having trouble getting the python requests package to run. I have searched around for answers, but it seems that the question is most often answered with instructions on installing the requests package, which you will see I have already done.
Before I start, my specs are as follows:
OS: MacOSX Catalina 10.15.7
Shell: iTerm2 Build 3.3.12
Python Versions:
System: 2.7.16
pyenv: 3.9.0
Use Case: I am experimenting with web scraping and am attempting to write a simple program that will scrape some data from a local car dealership's website (e.g. scrape info on cars listed under $20k).
Before starting the project, I installed the requests package with the following command:
% pip3 install requests
I then opened up a vim file and wrote the following, just to ensure that the requests package was working properly:
import requests
URL = 'cardealerurl.com/query'
page = requests.get(URL)
I saved the file as carScrape.py.
Then I went beck to the shell and executed the following:
python carScrape.py
on execution, I receive the following error message:
Traceback (most recent call last):
File "carScrape.py", line 1, in <module>
import packages.requests
ImportError: No module named packages.requests
Any help with this would be greatly appreciated. If more information is needed, please just let me know and I will provide whatever I can. Thank you all so much.
I was able to solve this by running the following commands:
% sudo -H pip3 uninstall pip
% python3 -m ensurepip
% pip3 install requests
This was after a pretty long chunk of time trying other solutions that did not work. I also had to start a new shell to get rid of the error message.

Module Not Found Error: No module named 'squarify'

On Jupyter notebook, running Python 3 code. Trying to build a squarify Tree map.
When I run the code:
import squarify as sq
ModuleNotFoundError arrises. "No Module named 'squarify'."
Although I know there such a module.
Can someone help me?
I've tried to put
path/to/python -m pip install squarify
and
install squarify
in the cell, but to no avail.
import squarify as sq results in:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-43-d5603c2d6e58> in <module>
6 #Put a title on the chart
7
----> 8 import squarify as sq
9
10 #determine count for each type weathersit
ModuleNotFoundError: No module named 'squarify'
Thank you for all the answers to this question. I have since figured it out. Best advice I can give is to search Anaconda Prompt (Anaconda 3) on your computer, which will pull up a script. Then simply time pip install squarify.
Once this loads the program on your computer, try to import squarify as sq on your jupyter notebook, and the chunk should now work without errors.
Good luck to everyone, and thank you for all the help!
Zach
In my case squarify was added to miniconda - I was not able to import it into anaconda.
I opened Anaconda Navigator - uninstalled miniconda.
Updated anaconda and imported squarify to anaconda (anaconda prompt) and it work now via simple import squarify cmd.
For me I opened Anaconda Navigator, went to Environments base(root) and clicked Open Terminal. I run the below command in the terminal and all was OK.
pip install squarify

ModuleNotFoundError when run python script but in cmd prompt type 'import colorama' is works

Window10 and Python3.7.4
The lib I am trying to use is 'colorama'.
When i run the python script file (x.py) it cannot find the module in the line which is "import colorama", but when i open a cmd and enter python env then type 'import colorama', it works. Does any one know what's the reason?
'''
>>>D:\Scratch\commands>mypythonscript.py
>>>Traceback (most recent call last):
>>> File "D:\Scratch\commands\mypythonscript.py", line 12, in <module>
>>> from colorama import init, Fore, Back, Style
>>>ModuleNotFoundError: No module named 'colorama'
'''
I don't know why this issue arise but maybe I installed VS2019. Before this, it worked fine for me.
Try to find which python your are working with using SYS module with its VERSION method in this way:
import sys
print(sys.version)
And then verify if you are using the same python version as you are using on cmd.
Another problem could be the path of your module, try to locate it with the "magical method" of your module installed, for example in this case:
import colorama
print(colorama.__file__)
And then verify if colorama is in this path: ".../Python37/lib/site-packages/colorama"
if not, download COLORAMA from here:
https://www.lfd.uci.edu/~gohlke/pythonlibs/
unzip it with 7ZIP
and all unzip files copy to : ".../Python37/lib/site-packages"
don't worry for the module version, colorama is for all python versions.
NOTE: this only works for windows version.

python module not found error

This question has been asked a few times, but the remedy appears to complicated enough that I'm still searching for a user specific solution.
I recently installed Quandl module using pip command. Even after successful installation my python idle is still showing
Traceback (most recent call last):
File "F:\Python36\Machine Learning\01.py", line 3, in <module>
import Quandl
ModuleNotFoundError: No module named 'Quandl'
I have used import command in my code.
I am using python 3.6.1 version.
I am working on a windows 10 Desktop.
I have also tried re-installation of module.
You can better navigate to your python scripts folder and open a command window there and try pip3 install quandl .Hope this helps.

Anaconda3-4.3.1 installation on Linux - Spyder won't launch (PyQt5.QtWebEngineWidgets)

I just installed the above mentioned Anaconda version. Jupyter works fine, but I can't launch Spyder as I get
File "/proj/mianxx/anaconda3/lib/python3.6/site-packages/qtpy/QtWebEngineWidgets.py", line 22, in <module>
from PyQt5.QtWebEngineWidgets import QWebEnginePage
ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/proj/mianxx/anaconda3/bin//spyder", line 6, in <module>
sys.exit(spyder.app.start.main())
File "/proj/mianxx/anaconda3/lib/python3.6/site-packages/spyder/app/start.py", line 103, in main
from spyder.app import mainwindow
File "/proj/mianxx/anaconda3/lib/python3.6/site-packages/spyder/app/mainwindow.py", line 92, in <module>
from qtpy import QtWebEngineWidgets # analysis:ignore
File "/proj/mianxx/anaconda3/lib/python3.6/site-packages/qtpy/QtWebEngineWidgets.py", line 26, in <module>
from PyQt5.QtWebKitWidgets import QWebPage as QWebEnginePage
ImportError: /proj/mianxx/anaconda3/lib/python3.6/site-packages/PyQt5/../../../././libgsttag-1.0.so.0: undefined symbol: g_mutex_init
I am too much of a noob to take it from here...Any hints?
I've checked This GIT entry but I can't make much of it. It also seems old, despite being open.
EDIT
The issue appears to be related to tcsh, which is the default shell called.
If one issues
bash
LD_LIBRARY_PATH= spyder
This works and launches spyder correctly. However,
bash
spyder
will generate the same error as above.
Thanks to #Carlos Cordoba for his help.
Thanks for Carlos Cordoba's help, When I try to use:
LD_LIBRARY_PATH= spyder
in terminal, it really works but 'spyder' can't. Then I use:
sudo gedit ~/.bashrc
to open bashrc, write
export LD_LIBRARY_PATH= spyder:$LD_LIBRARY_PATH
save and open terminal with:
source ~/.bashrc
retry enter:
spyder
in terminal, works!
UPDATE
There is still something wrong when I write LD_LIBRARY_PATH= spyder in bashrc, every time when I open terminal, there is an error shows that space shouldn't write before spyder, but when I alter LD_LIBRARY_PATH= spyder into LD_LIBRARY_PATH=spyder, Spyder won't launch again, So there are two ways can solve this problem:
Don't mind see warning every time you open terminal
Use LD_LIBRARY_PATH= spyder open spyder
I found the answer (work with Ubuntu 18.04)
Check the version of pyqt
conda list pyqt
if it is 5.6.x
It won't work so I resorted to this simple command:
conda install pyqt=5.9.2
(and later also to
qt=5.9.5 qtpy=1.4.1 check all with conda list qt)
then you're good to launch spyder
More info on lixun's answer. In fact you may do
$ export LD_LIBRARY_PATH=
$ spyder
and it will work without any warning. Seasoned spyder/qt/anaconda specialists may be able to explain why. I do not feel this is a good solution. It is just a workaround.
I am using anaconda on Ubuntu 16.04.

Resources