ImJa
ImJa

Reputation: 125

I want to use both python 2.7 and 3.x in jupyter

I want to use use both python 2.7 and 3.x in jupyter. so I create python 2.7 kernel. but I can't import several libraries like numpy, matplotlib, scipy and so on in jupyter. then I installed a lot of libraries in python 2.7 kernel. I think it's so terrible idea. are there any idea to solve my problem??

Upvotes: 0

Views: 87

Answers (1)

Steve Barnes
Steve Barnes

Reputation: 28370

Obviously you can only use from within a specific kernel the libraries that that kernel has available so if you are trying to do the same basic things you need to have the same set of libraries available.

One trick that can help to shortcut this process is:

On Windows:

py -3 -m pip freeze > liblist.txt

Will give you a list of the current pip installed libraries, with versions, in Python 3 so review the contents and delete the lines containing any that you probably don't need then, it is probably also worth stripping the ==version from each line:

py -2 -m pip install -r liblist.txt

Should install them for you. If you add the --user flag your libraries will be added to the user space which may save some permissions problems.

On OS-X/Linux you can do the same but need to use python3 and python2 rather than py -3 & py -2 and if you do not use the --user flag you are likely to have to start the second command with sudo python2 rather than py -2 and then enter the password when prompted.

Upvotes: 1

Related Questions