C++ 14 kernel for Jupyter
Project description
This repo is originally created by Brendan Rius - `C Kernel for Jupyter`
You can see the original project at https://github.com/brendan-rius/jupyter-c-kernel
Plus, this C++ kernel only uses C++ 14. The others are being developed
(or not, who knows 😅)
C++ 14 kernel for Jupyter
Installation
:warning:
This kernel only works on Linux and macOS. If you want to use it on Windows, please consider using WSL, Docker, or using a virtual machine.
Normally, your target machine must meet these requirement packages before installing and using jupyter-cpp-kernel
.
g++
python3
,python3-pip
jupyter
(recommendjupyterlab
)
Install from PyPI
Installing on macOS
:warning:
You must all requirements above before doing anything else I don't use macOS too regularly, so I don't know how macOS get these packages But you can follow installation instructions on the Internet After that, you can copy this script and install the kernel
pip install jupyter-cpp-kernel
install_cpp_kernel --user
Installing on Debian/Ubuntu
sudo apt update && sudo apt full-upgrade -y
sudo apt install -y g++
sudo apt install -y python3 python3-pip
sudo pip install --upgrade pip
sudo pip install jupyter # Or jupyterlab. Using `sudo` to install to the main packge
sudo pip install jupyter-cpp-kernel # Can be `sudo`, but using it with caution. Only for large deployment Jupyter server
install_cpp_kernel --user # Can be `sudo`, but using it with caution. Only for large deployment Jupyter server
Install from GitHub repo
Installing on macOS
:warning:
You must all requirements above before doing anything else I don't use macOS too regularly, so I don't know how macOS get these packages But you can follow installation instructions on the Internet After that, you can copy this script and install the kernel
pip install git+https://github.com/takinekotfs/jupyter-cpp-kernel.git
install_cpp_kernel --user
Installing on Debian/Ubuntu
sudo apt update && sudo apt full-upgrade -y
sudo apt install -y g++
sudo apt install -y python3 python3-pip
sudo pip install --upgrade pip
sudo pip install jupyter # Or jupyterlab. Using `sudo` to install to the main packge
sudo pip install git+https://github.com/takinekotfs/jupyter-cpp-kernel.git
install_cpp_kernel --user # Can be `sudo`, but using it with caution. Only for large deployment Jupyter server
Contributing
You can clone, create a fork or import this repo whenever you want.
Please follow the GitHub standards and the license
Sample codes
:warning:
Raw input into program is still not completed yet. You may
cannot
usingcin
or any user input parameter.For the best practices, you shouldn't write
using namespace std;
because of the conflicts between thenamespace
. This problem doesn't come from the interpreter, it's actually the problem ofg++
globally
Hello world
#include <iostream>
int main() {
std::cout << "Hello World" << std::endl;
return 0;
}
Declare variable (int
) and take a math of them
#include <iostream>
#include <cmath>
int main() {
int x = 3, y = 6;
std::cout << "Sum of x and y is " << x + y << std::endl;
std::cout << "Subtract of x and y is " << x - y << std::endl;
return 0;
}
Condition
With If...else...
#include <iostream>
int main() {
bool isMale = false;
if (isMale) {
std::cout << "Male" << std::endl;
}
else {
std::cout << "Is not Male" << std::endl;
}
return 0;
}
With switch...case...
#include <iostream>
int main() {
int number = 1;
switch (number) {
case 1:
std::cout << "1" << std::endl;
case 2:
std::cout << "2" << std::endl;
default:
std::cout << "Not defined" << std::endl;
}
return 0;
}
Loop
For float condition
#include <iostream>
int main() {
int lim = 10;
for (int i = 0; i < lim; i++) {
std::cout << i << std::endl;
}
return 0;
}
For fixed condition
#include <iostream>
int main() {
int lim = 0;
while (lim < 10) {
std::cout << lim << std::endl;
lim++;
}
return 0;
}
Exception handler
#include <iostream>
int main() {
std::cerr << "Exception happened";
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for jupyter_cpp_kernel-1.0.0a2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85ef25df894f73b5bc0829c7a5f6eef217f5ee291c22adddbb0f5df932bbe6c7 |
|
MD5 | 7cd08b1a72fcaaa14b81b0a83b4a12b1 |
|
BLAKE2b-256 | 75188753cc04893d9ebf9532cfbaf906b808e6e6ca8301a2f0fcb0441535fd96 |
Hashes for jupyter_cpp_kernel-1.0.0a2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c73db909eb3196fdd8e7c55b9f2bd11b9c5ffbb5a14a495c9d4506b7715677f4 |
|
MD5 | 08d54ad7cc9c9e68d004463e717bb021 |
|
BLAKE2b-256 | 67b1598ed7bd6aadb8da48004f888a2c54914534b7dd38d76853ac3e7cc34e4a |