Environment Setup
Check Environment Status
Verify if the Python environment is ready:
import { ExuluPython } from '@exulu/backend';
if (ExuluPython.check()) {
console.log('Python environment is ready');
} else {
console.log('Python environment needs setup');
}
Validate Environment
Get detailed validation information:
import { ExuluPython } from '@exulu/backend';
const validation = await ExuluPython.validate();
if (validation.valid) {
console.log('✓ Environment is valid');
} else {
console.error('✗ Environment issue:', validation.message);
}
Force Rebuild
Rebuild the Python environment from scratch:
import { ExuluPython } from '@exulu/backend';
const result = await ExuluPython.setup({
force: true,
verbose: true
});
Setup Options
The setup() method accepts the following options:
Force reinstall even if environment already exists
Show detailed output during setup
Setup timeout in milliseconds (10 minutes)
Package root directory (auto-detected if not provided)
CI/CD Integration
GitHub Actions Example
name: Test
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: npm install
env:
# Enable Python setup in CI
SETUP_PYTHON_IN_CI: 1
- name: Run tests
run: npm test
Cache Python Environment
- name: Cache Python venv
uses: actions/cache@v3
with:
path: node_modules/@exulu/backend/ee/python/.venv
key: ${{ runner.os }}-python-${{ hashFiles('**/requirements.txt') }}
Troubleshooting
Python environment not found
Solution: Run the setup manuallyimport { ExuluPython } from '@exulu/backend';
await ExuluPython.setup();
Solution: Install Python 3.10 or higher# macOS
brew install python@3.12
# Ubuntu/Debian
sudo apt-get install python3.12
Then rebuild:await ExuluPython.setup({ force: true });
Solution: Increase timeout for long-running scriptsconst result = await executePythonScript({
scriptPath: 'ee/python/my_script.py',
timeout: 1200000 // 20 minutes
});
Solution: Rebuild the environmentawait ExuluPython.setup({ force: true });
Get Setup Instructions
Get helpful instructions for users:
import { ExuluPython } from '@exulu/backend';
const instructions = ExuluPython.instructions();
console.log(instructions);