Home  >  Article  >  Backend Development  >  Install PHP kernel under Jupyter Notebook

Install PHP kernel under Jupyter Notebook

藏色散人
藏色散人forward
2020-01-10 14:44:513269browse

I have recently been strongly attracted by Jupyter Notebook, an interactive notebook. Then after trying out its own Python kernel, I felt very good about this application as a whole, so I searched for other kernels it supports, including Jupyter Kernels.

I will introduce below how to install the PHP kernel under this application.

Installation steps

Install PHP kernel Jupyter-PHP

Environment requirements

1.PHP > ;= 7.0

2.Jupyter Notebook has been installed

3.Operation on Mac

Steps

1.Install Composer globally

$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer

2. Install the PHP-ZMQ extension

(1) Download and compile

$ git clone git://github.com/mkoppanen/php-zmq.git
$ cd php-zmq
$ phpize && ./configure
$ make && make install

(2) Modify the configuration

Modify the php.ini configuration and add `extension=/path/modules/zmq.so`

3. Downloadjupyter-php-installer.phar

4.Execute phar installation program

$ php jupyter-php-installer.phar install

5. The installation is successful, and the Jupyter-PHP kernel has been successfully installed.

Problems encountered and solved

Problem 1:

Compile PHP-ZMQ without autoconf and pkg-config

Solution:

    $ brew install autoconf
    $ brew install pkg-config

Problem 2:

No php.ini on Mac

Solution:

    $ sudo cp /etc/php.ini.default /etc/php.ini

Question 3:

The compiled extension zmq.so cannot be moved to the PHP default extension path /usr/lib/php/extensions/no-debug-non- zts-20160303/

Solution:

Because macOS System Integrity Protection (SIP) will prevent you from moving zmq.so to the default path, and I don’t want to turn off SIP. So the solution is to introduce extensions to write absolute paths

extension=/path/modules/zmq.so

Problem 4:

Use PHP kernel and print to print double output

Solution:

In fact, it is caused by the indistinguishable output between the printed value and the return value, and the author has not solved it yet. View issues

For more PHP related knowledge, please visit PHP Tutorial!

The above is the detailed content of Install PHP kernel under Jupyter Notebook. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete