Unable to plot graphs in iPython notebook, OSX 10.6 - ipython

i am trying to get inline graphs working in iPython notebook.. i begin by starting ipython with the command ipython notebook --pylab inline.
when i try to use the plot() function i get the following error
im running on OSX 10.6.8 and running ipython out of a virtualenv i have matplotlib and libpng installed
i also get this warning in the terminal
libpng warning: Application built with libpng-1.2.41 but running with 1.5.13
and plot() works normally when i use ipython in the terminal only when i use ipython notebook i get this error.. can someone help me with this..?

I had this problem as well. Another solution is to change the format which the notebook will render images in, from 'png' to 'svg'. This can be done in your config file. Mine is located at:
~/.ipython/profile_default/ipython_notebook_config.py
There is a line that looks like this
# c.InlineBackend.figure_format = 'png'
Uncommenting and changing to 'svg' did the trick for me:
c.InlineBackend.figure_format = 'svg'

This recent question on this board is similar to yours: matplotlib and libpng issues with ipython notebook
See if the solution there solves your issue.

so i finally got this working..
first off i had to get all my outdated ports updated
first i did port selfupdate
then sudo port update outdated
after that i reinstalled ipython using mac ports
sudo port install py27-ipython
then i had to install tornado and pyzmq respectively as ipython depends on it
sudo port install py27-tornado
sudo port install py27-zmq
and then ran it from the terminal
ipython notebook --pylab inline
everything works fine now i can plot maps inline in ipython!
i guess the reason it didnt work before was some problems with pip maybe its installing matplotlib that is build only for libpng 1.2.41 ??... so anyways if anyone else faces this problem id suggest reinstalling all the libraries and ipython via mac ports thats the only thing that worked for me.

Since it was complaining that the versions of libpng used for building and for running are different, I have reinstalled the matplotlib by forcing the path to includes.
CFLAGS="`libpng-config --cflags`" pip install matplotlib -I

Related

Jupyter Notebook Error: "Jupyter command `jupyter-notebook` not found."

I just downloaded vscode using homebrew and install python#3.11 using homebrew as well. I used pip3 install jupyter as I saw other recommend to fix this issue and still no luck. I have downloaded all the extensions on vscode and I have set the kernal to homebrew version of python and I still recieve this issue. Note that I have used notebooks in the past and have never gotten this issue so I am not really sure what it is this time. I have not installed anaconda.
I have tried uninstalling and installing the extensions but no luck. I have tried to pip3 uninstall jupyter, pip3 uninstall notebook and reinstall them and still no luck. I have tried to change the kernal to the default python3 on the mac and still nothing. My mac is m1 running on Ventura 13.2. I am able to run python code on regular python files just not using jupyter notebook. I followed the instructions how to set it up on vscode website but I got this error. Any help would be appreciated thank you.
I have same issue using VSCode on Mac OS.
VSCode's 'Jupyter' plugin is broken, causing VSCode unable to bind with python interpreter. Downgrading from v2023.1.2000312134 to v2022.11.1003412109 fixed my issue.
I had the same issue, running on m1 mac (Ventura 13.2). If you aren't already, make sure you are utilising a python virtual environment:
# Create a python virtual environment
$ python -m venv venv
# Activate your python virtual environment
$ source venv/bin/activate
Form your VSCode Command Palette (Shift+Command+P), search and then choose
Jupyter: Select Interpreter to Start Jupyter Server
You should then select the python version that is associated to your virtual environment (venv).

Pytorch module not found in VSCode

For the life of me I can't get the VSCode integrated terminal to correctly run a simple program that just has import torch in it. I've tried it all. I tried just installing pytorch via conda (I have Anaconda) inside the VSCode terminal, and then running my program inside the VSCode terminal as well. I tried creating a conda virtual environment, activating it, installing pytorch in it, and then running my program using the virtual environment. I tried switching the VSCode python to ('base': conda) and it didn't work. I tried switching the VSCode python to ('pytorch': conda) (I read this somewhere on StackOverflow), but I didn't find this. I tried uninstalling and re-installing the Python extension in VSCode. I tried just running python3 inside the VSCode terminal and seeing if >>> import torch would run, but it doesn't. I tried installing torch with pip or pip3 instead of with conda but it doesn't work, it just tells me that No matching distribution found for torch.
However, outside of VSCode, I can do import torch and it runs correctly. How could I solve this? I would very much prefer to use VSCode and its integrated terminal, but VSCode can't find pytorch for the life of me.
EDIT: Using MacOS Monterey and most updated python extension in VSCode

Plotly installed, but VSCode doesn't seem to think so

I'm trying to learn how to use Plotly using VSCode, but the minute I run my code from the terminal, it says ModuleNotFoundError: No module named 'plotly' Any idea why this is happening? Python is installed via Anaconda, and if I try to do pip install plotly it tells me it's already installed. I've tried nearly everything I can find about this issue and nothing works. Any suggestions would be appreciated.
I'll also add that when I do pip install plotly it gives the following:
Requirement already satisfied: plotly in /Users/username/opt/anaconda3/lib/python3.8/site-packages (4.14.3) Requirement already satisfied: retrying>=1.3.3 in /Users/username/opt/anaconda3/lib/python3.8/site-packages (from plotly) (1.3.3) Requirement already satisfied: six in /Users/username/opt/anaconda3/lib/python3.8/site-packages (from plotly) (1.15.0)
It's possible that you have multiple python versions installed and pip installed plotly for the wrong version. Try to do pip --version and in your code (before the plotly import) do
import sys
print(sys.version)
to see if the python versions match. If they don't, you may have to call pip3 install instead.
(Would have posted this as a comment, but don't have enough reputation).
Accidental fix found: I was working with the bash shell on the VS Code terminal. I switched to the zsh shell by doing exec zsh. When I ran the file using the zsh shell, everything worked.

Unreadable Notebook - Unsupported nbformat version 4 on windows

I finally was able to install ipython on my Windows 7 PC and it runs without any errors. The problem is that I used to code in ipython but in MAC. Now that I am trying to upload my previous notebooks I receive the following error:
Unreadable Notebook: MyFile.ipynb Unsupported nbformat version 4
I found this answer for my question but unfortunately that is not for windows and did not resolve my problem. It is worth to mention:
ipython --version
produces:
2.3.1
Any help or comment on this is much appreciated.
Thanks
It took me a while to figure this out but I got the first lead from user "cel". I used to have multiple versions of python (2.7 and 3.4). I removed python 3.4 because it's not compatible with spark yet. Next, I had to remove WinPython3.4 and replace it with WinPython2.7 so it can integrate with python 2.7 installed on my PC. Finally, I installed python 2.7.9 and set the C:/Python27/Script as a part of system environment variable. After doing all this I ran the following commands:
pip uninstall ipython
This helped me to remove older version of ipython. Then:
pip install ipython
This installed the latest version of ipython on my windows pc. Finally:
pip install notebook --upgrade
To upgrade notebook to latest version. Right now, ipython os installed and and should work fine doing this:
ipython notebook
Had no problem importing my previous .ipynb after all of the above.
Good luck to you all.
I have the same problem on Linux. Simply doing:
sudo pip install notebook --upgrade
worked for me. I have python 3.4 and 2.7 and unlike the answer by nimafl, there was no need for me to remove one them or to first uninstall ipython. A simple upgrade did the trick. Now instead of version 2.3.1 I have version 4.0.3 of ipython.

Can't get ipython console in spyder

I'm having trouble getting an ipython console in Spyder. It only offers a python interpreter under the "interpreters" menu.
I've seen this issue for a couple of others in Stackoverflow, but didn't have much joy with the proffered solutions.
I'm running linux Mint 16 and have installed both ipython (v 1.1.0) and Spyder (v 2.2.1) the easy way via the Mint Software Manager. I made sure that I also installed ipython-qtconsole and verified that I could run it from a terminal (i.e. ipython qtconsole).
I can activate an ipython console using the following commands in a Spyder python console:
import IPython
IPython.start_ipython()
though the font coloring is strange and doesn't work well on a white background (e.g. error messages in yellow and light green). It would be nice anyway to be able to start ipython the normal way from the Spyder menu.
You may want to install python-zmq for Python 2 and python3-zmq for Python 3.
I use Ubuntu 14.04, so:
sudo apt-get install python-zmq python3-zmq
I'm also using Linux Mint (18.1, at this time) and I have faced the same issue.
What solved this for me was installing Ipython3 Qt console (that, of course, should be Ipython Qt console if you're using Python 2.x).
In case you have it installed, check if you have the latest version
(In Linux Mint you can do this through Synaptic, aptitude or apt-get.)