Install PHP kernel under Jupyter Notebook

藏色散人
Release: 2023-04-08 08:02:01
forward
3257 people have browsed it

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
Copy after login

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
Copy after login

(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
Copy after login

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
Copy after login

Problem 2:

No php.ini on Mac

Solution:

    $ sudo cp /etc/php.ini.default /etc/php.ini
Copy after login

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
Copy after login

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!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template