1

I am using python 2.7 in Ubuntu and recently updated tensorflow 0.12.1. I installed jupyter today for my sample code of tf and I need to use matplotlib. It does not find module name matplotlib and ipython in tensorflow has same error.

1. How can I set path in virtualenv or ipython or jupyter?

After activate tensorflow, I need to use jupyter notebook.

This below in the script for error does not work.

import sys 

sys.path.append('my/path/to/module/folder') 

import module-of-interest

2. other information: My environments are below.

mickyefromsd@DEKSTOP~$source ~/tensorflow/bin/activate

When I find matplotlib by python script under TF condition and before TF activation, it has below;

/usr/lib/python2.7/dist-packages/matplotlib/

When I type 'which ipython', it has below (not by /usr/bin/ipython) ;

/home/mickeyfromd/tensorflow/bin/ipython

Btw, /tensorflow/lib/python2.7/site-packages/ it has ipython and jupyter.

(not in the same path of matplotlib)

3. My ipython under TF cannot find my existing matplotlib.

(tensorflow) mickeyfromd@DK-DESKTOP:~$ ipython

Python 2.7.11+ (default, Apr 17 2016, 14:00:29)

In [1]: import matplotlib ImportError: No module named matplotlib

4. I wanted to setup virtualenv, so I just run this

I followed this site. site:http://help.pythonanywhere.com/pages/IPythonNotebookVirtualenvs

(tensorflow) mickeyfromd@ipython kernelspec install-self --user ..... Installed kernelspec python2 in /home/mickeyfromd/.local/share/jupyter/kernels/python2

(tensorflow) mickeyfromd@DK-DESKTOP:~$

I cannot move the the folder (in the second step)

How can I make ipython to have path for Matplotlib?

1 Answer 1

2

That import error is due to change in environment of the jupyter notebook. You might have installed the packages in one environment and you are running the jupyter notebook in another environment.

  1. I have got two environments (envs) in my Anaconda folder ( I have Anaconda3 folder to be specific ).
  2. (windows key+cmd ) -> open the windows command prompt run as administrator.
  3. Activate (name of the environment) -> eg.: activate tensorflow-gpu
  4. Start installing packages using conda install

Note: For each environment you need to install all the packages you want to use, separately using the same process. This solution is for windows users, might work for linux users not sure though.

Additionally to make sure your conda environment is up to date run:

conda update conda

conda update anaconda

check this out : https://pradyumnamajumder.wordpress.com/2017/09/30/solution-to-the-python-packages-import-error-in-jupyter/

Sign up to request clarification or add additional context in comments.

2 Comments

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
Sure, I will edit and put it here as well. :) @BrandonMinnick

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.