Поиск по блогу

вторник, 1 декабря 2015 г.

Создаем для JuPyter возможность одновременной работаты c Python 2.7 Python 3.4

Одолели мысли по поводу использования notebook для отладки Javascript. Обнаружил, что с третьим питоном делать это можно очень просто. Здесь научился создавать пространство имен для python 3 conda create -n py3k python=3 anaconda, но долго не получалось запустить notebook так, чтобы в ней появились опции выбора переключения версий ядра между 2-ым и 3-им питоном. Надо было перегрузить компьютер. Здесь видео и с 10-к ссылок... на документацию. Там все просто...

IPython Notebook with in-browser Javascript Kernel
In-browser javascript kernel for Jupyter
Python 3 support in Anaconda Did you know that Anaconda has been supporting Python 3 for more than half a year? While the Anaconda installers use Python 2.7, it is quite easy to create new additional environments that provide Python 3.3 (and soon Python 3.4), as well as many scientific packages. This blog explains how this is done in detail.
Conda is an open source package management system and environment management system for installing multiple versions of software packages and their dependencies and switching easily between them
Anaconda Package List
New Advances in conda SAT solver The first iteration of conda was using a graph-based algorithm on top of hand-coded constraints to find a solution to the install dependency problem. With more and more packages being added to the Anaconda repository, we started seeing performance problems. This is when we started looking into using SAT solvers to solve the install dependency problem, as other package management systems, for example libzypp and Zero install use this approach already.

Writing a Node.js kernel for IPyton in half an hour To run a javascript kernel in-browser instead of remote via websockets, just clone this repo into your IPython kernels directory... Requires IPython ≥ 3

Оказывается, что можно сконфигуррировать ядро IPython так, что в Notebook можно сформировать доступ к единому пространству имен javascript из всех ячеек (две первые ссылки)

In [ ]:
cd $(ipython locate)/kernels
git clone https://github.com/minrk/jskernel
Cloning into 'jskernel'...
remote: Counting objects: 11, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 11 (delta 0), reused 11 (delta 0)
Unpacking objects: 100% (11/11), done.


You should now be able to select 'Javascript' from the kernel selection drop-down.

Requires IPython  3.

Однако, для этого нужен третий Питон, а в Анаконде он уже установлен, научимся его использовать

Starting from a regular Anaconda installation (Python 3 support in Anaconda)

If you have installed Anaconda from the full installer, there is a root environment which has Python 2.7 and all other packages.
What this means is that these packages are installed directly into the install prefix which was selected during the install process.
The conda package manager now allows creating new environments separately from the root environment. Since these additional environments are completely separate, they may contain a different major Python version. The following command would be used to create an Anaconda Python 3 environment named py3k:

In [ ]:
$ conda create -n py3k python=3 anaconda

Here python=3 and anaconda are package specifications, and it is the job of the SATsolver inside conda to find a consistent set of packages which satisfies these requirements. As the root environment uses Python 2, we had to specify the major version explicitly.

After adding the binary directory of the newly created environment to the PATH environment variable, which may be done using

In [ ]:
$ source activate py3k

Что мешает?

In [ ]:
C:\Users\alter_000>conda info
Current conda install:

             platform : win-64
        conda version : 3.18.6
  conda-build version : 1.14.1
       python version : 2.7.10.final.0
     requests version : 2.8.1
     root environment : C:\Users\alter_000\Anaconda  (writable)
  default environment : C:\Users\alter_000\Anaconda
     envs directories : C:\Users\alter_000\Anaconda\envs
        package cache : C:\Users\alter_000\Anaconda\pkgs
         channel URLs : https://repo.continuum.io/pkgs/free/win-64/
                        https://repo.continuum.io/pkgs/free/noarch/
                        https://repo.continuum.io/pkgs/pro/win-64/
                        https://repo.continuum.io/pkgs/pro/noarch/
          config file : None
    is foreign system : False


C:\Users\alter_000>
In [ ]:
!python --version


Посты чуть ниже также могут вас заинтересовать

Комментариев нет:

Отправить комментарий