Python/Ipython Importerror: No Module Named Site

ImportError: No module named IPython

Ok, finally i achieved my goal.

  1. I wrote ipython --version but i found, it was not installed.
  2. I tried to install it, with pip. I went to C:\Python27\Scripts, here is pip, you can try in this directory, or add to environment variables.
  3. I tried to install ipython, but i found a error

error: Unable to find vcvarsall.bat

so i installed visual studio c++ 9.0, the version to python 2.7.


  1. pip install ipython

ImportError: No module named when trying to run Python script

This issue arises due to the ways in which the command line IPython interpreter uses your current path vs. the way a separate process does (be it an IPython notebook, external process, etc). IPython will look for modules to import that are not only found in your sys.path, but also on your current working directory. When starting an interpreter from the command line, the current directory you're operating in is the same one you started ipython in. If you run

import os
os.getcwd()

you'll see this is true.

However, let's say you're using an ipython notebook, run os.getcwd() and your current working directory is instead the folder in which you told the notebook to operate from in your ipython_notebook_config.py file (typically using the c.NotebookManager.notebook_dir setting).

The solution is to provide the python interpreter with the path-to-your-module. The simplest solution is to append that path to your sys.path list. In your notebook, first try:

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

import module_of_interest

If that doesn't work, you've got a different problem on your hands unrelated to path-to-import and you should provide more info about your problem.

The better (and more permanent) way to solve this is to set your PYTHONPATH, which provides the interpreter with additional directories look in for python packages/modules. Editing or setting the PYTHONPATH as a global var is os dependent, and is discussed in detail here for Unix or Windows.

ipython iptest ImportError( no module named ipython)

I guess you create your virtual environment with --system-site-packages.

Try following steps:

  1. Exit virtual environment: deactivate
  2. Switch to superuser: su root
  3. Install jupyter outside the virtual environment: sudo pip3 install jupyter

Then enter your virtual environment and try again.



Related Topics



Leave a reply



Submit