Cannot convert jupyter notebook to pdf - python

I get the following error when I try to convert jupyter notebook to pdf.
I'd appreciate your help. Thank you.

sudo apt-get install texlive-xetex
will probably fix your issue

As the error says, you need to install xelatex and add it to your path so that the conversion can take place.
Can you follow the instruction here to install xelatex onto your system. Once done check in your cmd line that it is installed by doing the following,
latex --version
If this shows the version then it should work fine.
Edit:
Working Solution:
Ok. Thank you so much. It worked. I downloaded MikTex from (miktex.org/download). I made sure it is on the same path. Ran your command 'xetex --version' to make sure it's in the same path. Went back to jupyter notebook and was able to convert it to pdf. Thank you.
Possible Solution:
Go here go to 'JupyterLab' which will allow you to open jupyter notebooks. Once opened( it is slow, so be patient) open your local file and then simply export it to pdf. This will not require any dependencies like on local side.

Related

Saving all used packages and versions of a python project in a text file on windows?

I am trying to save the packages and versions used in my python project. I installed pipreqs but I don't know why it's not working. Maybe I'm not using it correctly. What I did is the following in my jupyter notebook:
pipreqs C:\Users\Documents\myproject\gitlab\Scripts\packages
When I run it, it says syntax error. I tried replacing path = r'C:\Users\Documents\myproject\gitlab\Scripts\packages' and it still didn't work.
I want the requirements.txt to be saved in this directory. Am I missing something? Can someone please guide me through how pipreqs works ? Thanks
Under windows, running pipreqs with normal windows paths work, eg
pipreqs.exe c:\MyProject
Works as requested, using python 3.7.8 and pipreqs 0.4.10.
The syntax error comes from one of your scripts, which pipreqs actually loads.
You should try to run your scripts one by one to find which of them is having the syntax error.
Good luck.

pip3 install of Jupyter and Notebook problem when running

I have tried all of the things here on stack and on other sites with no joy...
I'd appreciate any suggestions please.
I have installed Jupyter and Notebook using pip3 - please note that I have updated pip3 before doing so.
However when trying to check the version of both jupyter --version and notebook --version my terminal is returning no command found. I have also tried to run jupyter, notebook and jupyter notebook and I am still getting the same message.
I have spent nearly two days now trying to sort this out... I'm on the verge of giving up.
I have a feeling it has something to do with my PATH variable maybe not pointing to where the jupyter executable is stored but I don't know how to find out where notebook and jupyter are stored on my system.
many thanks in advance
Bobby
You should be able to run jupyter with python -m even if the PATH variable is not set up correctly.
python -m jupyter notebook
you can check the PATH variables on Windows if you search in with the windows search function for env and then click on Edit the system environment variables > Environment Variables....
The path variable is a list of paths that the terminal checks for commands.
I didn`t work on Mac for a long time, so not sure how similar linux and mac command line still are, but on debian you control your path variable like this.
View paths:
echo $PATH
/usr/local/bin:/usr/bin:/bin
Add a path:
export PATH=$PATH:/mynewpath
For constant export add to ~/.bashrc
To view the path of the pip package, you can use
pip3 show jupyter
When jupyter-notebook works and jupyter notebook does not. It looks to me like a symlink thing. Or a Mac-specific problem.
So to summarise this is what I have found on this issue (in my experience):
to run the jupyter app you can use the jupyter-notebook command and this works, but why? This is because, the jupyter-notebook is stored in usr/local/bin which is normally always stored in the PATH variable.
I then discovered that the jupyter notebook or jupyter --version command will now work if I did the following:
open my ./bash_profile file
add the following to the bottom of the file: export PATH=$PATH:/Users/your-home-directory/Library/Python/3.7/bin
this should add the location of where jupyter is located to your path variable.
Alternatively, as suggested by #HackLab we can also do the following:
python3 -m jupyter notebook
Hopefully, this will give anyone else having the same issues I had an easier time resolving this issue.
I've found a solution from the documentation over at Jupyter https://jupyter-notebook.readthedocs.io/en/stable/troubleshooting.html but I am still curious.
It states that to run the application to use the command jupyter-notebook and hey-presto! It does seem to work now. But, why is this when nearly everywhere else I have read that to run the app we just type the command jupyter notebook.
Also, if I do need to check the version of any of the Jupyter files how do I go about this now, if jupyter --version and notebook --version still don't work.
Also, how do I go about finding these files in my file system if I have no idea where they are located? And how do I go about adding these to my path so that I can, for example, check the version of these programs?
Will pip3 automatically update this software as and when needed?
Thanks again in advance
have you tried locate Jupiter? It may tell you where jupyter is on your system.
Also, why not try installing jupyter via anaconda to avoid the hassle?
I definitely would recommend going through anaconda which makes everything a lot easier.
The following is the link with step by step instructions: https://jupyter.readthedocs.io/en/latest/install.html

installing jupyter notebooks on macOS

when I do a pip install jupyter notebook, which it seems to install and then I run "jupyter notebook" it tells me that "zsh: command not found: jupyter"
Also does it matter using zsh on macOS?
Any suggestions too fix this issue?
Thanks!
Johnny
Make sure where juypter was installed is on your execution path in the zsh shell. (If "which jupyter" doesn't list a valid path, then that's your problem. :)
Should look something like this, but with the location on your machine:
(jupyter) c-67-188-202-51{rich:~/src/python/udemy/completePythonBootcamp} which jupyter
/Users/rich/src/python/udemy/completePythonBootcamp/jupyter/bin/jupyter
I faced a similar problem. If you've installed it using --user try to add to your path variable in .zshrc a path like this /Users/<name_of_your_user>/Library/Python/3.8/bin. Replace <name_of_your_user> with name of the user and maybe you have another version of python and the folder 3.8 should be replaced with the corresponding version. It helped me. Please check if that works for you and mark the question as solved if it did.

A way to quick preview .ipynb files

Got a small basic question. I use a Mac, and I used to work in .py files with Sublime 3. One of the things I liked was that when Sublime is closed, for a given file in a folder--if I'm looking for a bit of code--I could hit the spacebar and Macs open a quick preview of the .py document.
Now I'm working in Jupyter Notebook and saving everything as .ipynb files. Now I can't hit the spacebar and glance at files--I launch JN from the command land and it's far slower.
I suspect there are quicker ways to open .ipynb files in browser windows, but what I really want to know is is there a way to quickly preview those file contents from my desktop? Alternatively, is there a way to work in Jupiter Notebook but save the files as .py (and later seamlessly reopen in JN), such that I could still use the great old spacebar trick?
Thanks for you patience with a pretty small question :)
It's been a while since the last answer, but just in case anyone else is looking to use Mac Quicklook to preview Jupyter Notebooks .ipynb files, this app does the job:
Jupyter Notebook Viewer - https://github.com/tuxu/nbviewer-app
You can either download the app from that page or install using brew cask
brew cask install jupyter-notebook-viewer
If the preview is not working you should reload quicklook.
Just open a terminal windows and run. It worked for me on macOS High Sierra.
qlmanage -r
Now enjoy quicklook preview for Jupyter Notebook files :)
I had this same question at the weekend.
I came across two things:
a) this project on Github: https://github.com/jendas1/jupyter-notebook-quick-look
and
b) The Jupyter app which allows you to open Notebooks in Finder on the mac: https://github.com/jendas1/JupyterApp
Caveat - I book marked these, but due to other work I have not had time to download, install or test these.
If you do, please let me know how you get on!
As an update to the previous answers, I'd like to recommend nbviewer.js which is a client-side ipynb renderer. You can use it online at https://kokes.github.io/nbviewer.js/viewer.html
In case anyone wants to do the same on linux, you can check this out
nb-viewer which lets you preview Jupyter notebooks with a double click!
Update for the most recent version of MacOS (tested on macOS Big Sur v11.6) & newer brew versions:
To install Jupyter Notebook Viewer - https://github.com/tuxu/nbviewer-app follow these steps:
brew install --cask jupyter-notebook-viewer
Manually start /Applications/Jupyter Notebook Viewer.app using command + open (to allow a third-party app to be started)
qlmanage -r

'pip' is not recognized as an internal or external command, operable program or batch file

I'm trying to install Tweepy using pip, but I keep getting this as the response:
I've seen similar problems and people always suggest adding C:\Python34\Scripts to your PATH. Here is what happens when I try and do that:
Then when I do echo %PATH% it doesn't show the path that I added. Using pip still does not work.
How do I make it to where I am able to use pip? I looked through multiple other questions that were VERY similar to mine, but none of the solutions worked.
Thanks for the help in advance!
I would recommend using this guide for adding a new folder to your system path, normally works for me. It goes through a GUI instead of adding through the command line.
http://windowsitpro.com/systems-management/how-can-i-add-new-folder-my-system-path
A second solution is that you can just cd into the directory that contains pip and use it from there each time, but thats only if nothing else works.
It seems like you are using windows so you need to download the get-pip.py and run like this.
Path_to_your_Python.exe\python.exe Path_to_get-pip.py\get-pip.py tweepy
Here is the link for download get-pip.py

Categories