Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Successful in 3s
Deploy to Testnet / deploy-testnet (push) Successful in 1m6s
Documentation Validation / validate-docs (push) Failing after 9s
Documentation Validation / validate-policies-strict (push) Successful in 5s
Multi-Node Stress Testing / stress-test (push) Successful in 3s
Node Failover Simulation / failover-test (push) Failing after 4s
- Moved ai-economics/ to docs/ai-economics/ - Moved completion/ to docs/completion/ - Merged cli/ with docs/cli/ - Merged infrastructure/ with docs/infrastructure/ - Moved planning/ to docs/planning/ - Moved requirements/ to docs/requirements/ - Moved workspace/ to docs/development/workspace/ - Moved 1_files.md to docs/reference/REPOSITORY_STRUCTURE.md - Moved 2_roadmap.md to docs/ROADMAP.md - Moved 3_infrastructure.md to docs/infrastructure/INFRASTRUCTURE.md - Moved SECURITY.md to docs/security/SECURITY.md - Moved PROJECT_STRUCTURE.md to docs/archive/GPU_PROJECT_STRUCTURE.md - Moved WORKING_SETUP.md to docs/guides/getting-started/WORKING_SETUP.md - Moved E2E_TEST_CREATION_SUMMARY.md to docs/reports/E2E_TEST_CREATION_SUMMARY.md - Moved SQLMODEL_METADATA_FIX_SUMMARY.md to docs/reports/SQLMODEL_METADATA_FIX_SUMMARY.md - Moved GITHUB_PULL_SUMMARY.md to docs/reports/GITHUB_PULL_SUMMARY.md - Moved GIFT_CERTIFICATE_newuser.md to docs/guides/getting-started/GIFT_CERTIFICATE.md - Moved user_profile_newuser.md to docs/guides/getting-started/USER_PROFILE.md - Moved aitbc.md to docs/infrastructure/NODE_AITBC.md - Moved aitbc1.md to docs/infrastructure/NODE_AITBC1.md - Updated project/README.md with new documentation locations - Removed empty subdirectories from docs/project/ - Created docs/MERGE_PLAN.md for reference
5.0 KiB
5.0 KiB
AITBC Central Virtual Environment Guide
Last Updated: 2026-03-29
Version: 3.2 (Virtual Environment Standardization)
Overview
AITBC now uses a central Python virtual environment to manage all dependencies consistently across services. This eliminates conflicts with system Python packages and provides a clean, isolated environment for all AITBC components.
🏗️ Virtual Environment Structure
/opt/aitbc/
├── venv/ # Central virtual environment
│ ├── bin/ # Python executables and scripts
│ ├── lib/ # Installed packages
│ └── pyvenv.cfg # Virtual environment configuration
├── requirements.txt # Central dependency list
├── aitbc-env # Environment wrapper script
└── apps/ # AITBC applications
🚀 Quick Start
Activate Virtual Environment
# Use the environment wrapper (recommended)
/opt/aitbc/aitbc-env
# Or activate directly
source /opt/aitbc/venv/bin/activate
CLI Usage
# Start interactive shell with CLI access
/opt/aitbc/aitbc-env
# Use CLI commands directly
/opt/aitbc/aitbc-env aitbc --help
# Run Python scripts with venv
/opt/aitbc/aitbc-env python script.py
📦 Package Management
Dependencies Included
- Web Framework: FastAPI, Uvicorn
- Database: SQLAlchemy, SQLModel, Alembic
- Security: Cryptography, PyNaCl
- CLI Tools: Click, Rich, Typer
- AI/ML: NumPy, Pandas, OpenCV
- Monitoring: Prometheus Client, Structlog
Installing New Packages
# Activate environment first
/opt/aitbc/aitbc-env
# Install packages
pip install package-name
# Update requirements.txt
pip freeze > /opt/aitbc/requirements.txt
🔧 Service Integration
Updated Services
All major AITBC services now use the central virtual environment:
- ✅ Wallet Service:
/opt/aitbc/venv/bin/python - ✅ Exchange API:
/opt/aitbc/venv/bin/python - ✅ Coordinator API:
/opt/aitbc/venv/bin/python - ✅ Blockchain Node:
/opt/aitbc/venv/bin/python
SystemD Configuration
Services automatically use the central venv via updated ExecStart paths:
[Service]
ExecStart=/opt/aitbc/venv/bin/python service_script.py
🛠️ Development Workflow
Development Environment
# Activate for development
/opt/aitbc/aitbc-env
# Run development servers
cd /opt/aitbc/apps/coordinator-api
uvicorn app.main:app --reload
# Run tests
pytest tests/
Environment Variables
The environment wrapper sets up:
PYTHONPATH=/opt/aitbc/packages/py/aitbc-sdk/src:/opt/aitbc/packages/py/aitbc-crypto/src
AITBC_VENV=/opt/aitbc/venv
PATH=/opt/aitbc/venv/bin:$PATH
🔍 Troubleshooting
Common Issues
Service Not Starting
# Check if venv exists
ls -la /opt/aitbc/venv/
# Check service status
sudo systemctl status aitbc-service-name
# Check logs
sudo journalctl -u aitbc-service-name -n 20
Missing Packages
# Install missing package
/opt/aitbc/aitbc-env pip install package-name
# Update all services
sudo systemctl restart aitbc-*
Import Errors
# Check PYTHONPATH
echo $PYTHONPATH
# Verify package installation
/opt/aitbc/aitbc-env python -c "import package_name"
Recreate Virtual Environment
# Backup current requirements
cp /opt/aitbc/requirements.txt /tmp/
# Remove and recreate
sudo rm -rf /opt/aitbc/venv
sudo python3 -m venv /opt/aitbc/venv
sudo chown -R root:root /opt/aitbc/venv
# Install packages
source /opt/aitbc/venv/bin/activate
pip install -r /opt/aitbc/requirements.txt
📋 Management Commands
Virtual Environment
# Check Python version
/opt/aitbc/aitbc-env python --version
# List installed packages
/opt/aitbc/aitbc-env pip list
# Check package details
/opt/aitbc/aitbc-env pip show package-name
Services
# Restart all services with venv
sudo systemctl restart aitbc-wallet aitbc-exchange-api
# Check service status
sudo systemctl status aitbc-*
# View service logs
sudo journalctl -u aitbc-service-name -f
🎯 Best Practices
- Always use the environment wrapper (
/opt/aitbc/aitbc-env) for consistency - Update requirements.txt when adding new packages
- Test services after dependency updates
- Monitor disk space - venv can grow with many packages
- Keep dependencies minimal - only install what's needed
🔄 Migration Notes
From System Python
- No more
--break-system-packagesneeded - Clean separation from OS packages
- Consistent package versions across services
From Multiple Venvs
- Single source of truth for dependencies
- Easier maintenance and updates
- Reduced disk usage
📚 Additional Resources
Next Steps: Use /opt/aitbc/aitbc-env for all AITBC development and operations.