# pynode-fix

> Node Python interopability

Latest version **0.4.7** (published 2020-01-19) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install pynode-fix
pnpm add pynode-fix
yarn add pynode-fix
bun add pynode-fix
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.4.7 |
| Published | 2020-01-19 |
| First published | 2020-01-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 1 |
| Unpacked size | 34.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Author | Sunoo |
| Maintainers | sunookitsune |
| Keywords | node.js, python |

## Links

- npm: https://www.npmjs.com/package/pynode-fix
- Homepage: https://github.com/Sunoo/PyNode
- npm.io page: https://npm.io/package/pynode-fix

## Dependencies (1)

- [node-addon-api](https://npm.io/package/node-addon-api.md) ^1.7.1

## Recent versions

- 0.4.7 (latest) — 2020-01-19

## README

# PyNode

[![Build Status](https://travis-ci.org/fridgerator/PyNode.svg?branch=master)](https://travis-ci.org/fridgerator/PyNode)
	
### Call python code from node.js

**Node v10 or above is required**

**Only tested with python 3.6.x and python 3.7.x.  Probably wont work with Python 2.7**

## Installation

**BEFORE NPM INSTALL OR YARN INSTALL**

* Make sure `python` in your system `PATH` is the correct one: `python --version`
* **Linux and Mac only**: make sure `python-config` is also in your path and is from the correct python installation.  You may have to symlink `python3-config` to `/usr/local/bin`.
* `yarn add @fridgerator/pynode` or
`npm install @fridgerator/pynode`

## Usage

In a python file `test.py`:

```python
def add(a, b):
  return a + b
```
in node:

```javascript
const pynode = require('@fridgerator/pynode')

// Workaround for linking issue in linux:
// https://bugs.python.org/issue4434
// if you get: `undefined symbol: PyExc_ValueError` or `undefined symbol: PyExc_SystemError`
pynode.dlOpen('libpython3.6m.so') // your libpython shared library

// optionally pass a path to use as Python module search path
pynode.startInterpreter()

// add current path as Python module search path, so it finds our test.py
pynode.appendSysPath('./')

// open the python file (module)
pynode.openFile('test')

// call the python function and get a return value
pynode.call('add', 1, 2, (err, result) => {
  if (err) return console.log('error : ', err)
  result === 3 // true
})
```

---
_Source: https://npm.io/package/pynode-fix · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
