简体   繁体   中英

ipython using python3.4 rather than python3.6

I'm working on a ubuntu 14.04 machine with python3.6 installed. When I bring up the python shell using the "python3" command it invokes the python3.6.1 version as shown below and I'm successfully able to import pandas library

python3
Python 3.6.1 (default, Jun 13 2017, 21:37:44) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.    
>>> import pandas
>>>

But when I invoke the ipython shell by the command ipython3, it is using python 3.4.3 as shown below and I'm unable to import the pandas library. How do I tell ipython3 to use python3.6.1 version?

ipython3
Python 3.4.3 (default, Nov 17 2016, 01:11:57) 
Type "copyright", "credits" or "license" for more information.
IPython 1.2.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
In [1]: import pandas
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-d6ac987968b6> in <module>()
----> 1 import pandas
ImportError: No module named 'pandas'

How can I deal with multiple versions of python to avoid such problems?

I've had this problem when I've accidentally been in the wrong environment invoking ipython (or a new environment where it isn't installed yet). If you have ipython installed in your root environment or anywhere else on your path it will default to that instead, fairly silently.

To check do a 'pip list', where you are invoking ipython. If it isn't listed, install it with 'pip install ipython' and then rerun.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM