Python qtConsole and Spyder: Problems with loading modules

Viewed 831

I am using Anaconda with Python 2.7 on Windows. I want to use Jupyter QtConsole but I am running into problems when I want to load certain modules. An example: I try to load (in the root environment) pandas. First I do this within Spyder. The Consol in Spyder is:

Python 2.7.13 |Continuum Analytics, Inc.| (default, May 11 2017, 14:07:41) [MSC v.1500 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.

IPython 5.3.0 -- An enhanced Interactive Python.

I can import pandas without any problems: import pandas

Then I try the same thing in the Jupyter QtConsole.

Jupyter QtConsole 4.3.1
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.

IPython 4.1.1 -- An enhanced Interactive Python.

When I try to import pandas import pandas, I get the error message:

ImportError                               Traceback (most recent call last)
<ipython-input-1-d6ac987968b6> in <module>()
----> 1 import pandas

ImportError: No module named pandas

When I try to install pandas in the qt console with !pip install pandas i get the following error message:

Requirement already satisfied: pandas in c:\programdata\anaconda2_32\lib\site-packages
Requirement already satisfied: python-dateutil in c:\programdata\anaconda2_32\lib\site-packages (from pandas)
Requirement already satisfied: pytz>=2011k in c:\programdata\anaconda2_32\lib\site-packages (from pandas)
Requirement already satisfied: numpy>=1.7.0 in c:\programdata\anaconda2_32\lib\site-packages (from pandas)
Requirement already satisfied: six>=1.5 in c:\programdata\anaconda2_32\lib\site-packages (from python-dateutil->pandas)

The same thing is withing Jupyter notebook. I have no problems with loading e.g. import numpy or import scipy. Furthermore, I can't load modules that were not pre-installed, e.g. import tzwhere in qtConsole or Jupyter notebook. But I can load all modules in Spyder. Thank you very much for your help.

1 Answers

How are you opening the qt console? If you open it from the shell and the conda environment is not the active one then you won't have access to it or installed modules. Below is probably easiest way to achieve what you want to do. Enter the commands in whichever console you are using.

  1. You can see the different conda environments available to you by running the following command.

conda env list

  1. The activate the one you want by running

conda activate {env_name}

  1. Run juypter console by runnning

jupyter qtconsole

Provided its installed in the environment.

More info available here managing conda environments

Related