Skip to content

Creating a Virtual Environment

Rose Heart edited this page Feb 10, 2025 · 2 revisions

Creating a Virtual Environment

Modern Linux distributions prioritize security and stability, restricting modifications to critical system areas, particularly when it comes to installing Python modules in global directories. This is essential to prevent unintended changes that might disrupt system operations. To overcome this limitation, Python Virtual Environments are employed, allowing developers to create isolated spaces for each project. These environments ensure that project dependencies do not interfere with the system’s Python installation.

This guide outlines the steps for setting up a Python virtual environment, emphasizing a philosophy that avoids placing non-system files in system areas. This approach not only adheres to best practices for security but also makes it easier to manage a VPS, especially with regard to backups.

The Instructions

These instructions are for Ubuntu 20.04, but should easily be adaptable to other methodoloies. These instructions only need to be done ONCE

1. apt upgrade

The apt upgrade command upgrades all installed packages to their latest versions. This step ensures that your system is up-to-date, especially for system libraries and tools that may interact with Python and other programming languages.

2. apt update

The apt update command fetches the latest package index files from the system’s configured package sources. By running this command, you ensure that your package manager is aware of the latest updates and available software.

Running apt update prior to upgrading packages ensures you have the most up-to-date information, allowing you to upgrade the system packages efficiently.

3. apt install python3-venv

This command installs the python3-venv package, which is necessary to create Python 3 virtual environments. While the venv module is part of the Python standard library, it is not always installed by default in some Linux distributions.

Installing python3-venv ensures that you can create isolated Python environments for your projects without interference from the system’s global Python setup.

4. python3 -m venv /home/RAPMD

This command creates a Python virtual environment within the directory /home/RAPMD. Here's a breakdown of the components:

  • python3: Specifies that Python 3 should be used.
  • -m venv: Runs the venv module to create the environment.
  • /home/RAPMD: The directory where the virtual environment will be created.

The choice of /home/RAPMD is specific to Jackrabbit Relay and the unique software philosophy behind it. The directory is intentionally selected to reflect the purpose of the software, ensuring that non-system files are stored outside of critical system areas. This not only adheres to a principle of separating software from system files but also helps make managing your VPS easier, particularly when performing backups. For clarity, /home/RAPMD is uniquely associated with Jackrabbit Relay and the user's software, offering a sense of structure that aligns with their approach to software deployment.

5. source /home/RAPMD/bin/activate

After creating the virtual environment, the source command is used to activate it. This modifies the shell session to use the Python interpreter and packages contained within the virtual environment instead of the system-wide Python installation.

Activating the environment ensures that all Python commands (e.g., python or pip) will be directed to the virtual environment, keeping the project dependencies separate from the global Python installation.

Automating Activation

To make it easier to use the virtual environment every time you open a terminal session, you can add the following line to the end of your .bashrc file:

source /home/RAPMD/bin/activate

Steps to Add Activation to .bashrc:

  1. Open the .bashrc file in a text editor:

    nano ~/.bashrc
  2. Scroll to the end of the file and add the following line:

    source /home/RAPMD/bin/activate
  3. Save and exit the editor (e.g., CTRL+O, Enter, CTRL+X in nano, or your perfered keys for a modified nano).

Effect:

Once added, the virtual environment will automatically activate every time a new terminal session starts. This removes the need to manually activate the environment each time, allowing for a seamless development experience.


By following these instructions, you will have set up an isolated Python environment, avoiding potential conflicts with the system-wide Python setup. The choice of storing the virtual environment in /home/RAPMD reflects the specific philosophy behind Jackrabbit Relay and the user's software, ensuring better VPS management and facilitating easier backups by keeping non-system files separate from critical system directories.

Adding the activation command to .bashrc automates the process, ensuring that the virtual environment is always ready when you open a new terminal session, streamlining your development workflow.

Now you can follow the rest of the Jackrabbit Relay Install and Setup.

RAPMD Crypto: Automated algorithmic trading done right

Jackrabbit support server

JSON Validator

Frequency Weighted OrderBook Analysis

Advanced Research

Introduction

Jackrabbit Relay
Introduction
Risks
Disclaimer
Notes
Video
Supported Exchanges/Brokers
Security and firewall
Installation
Updating
Configuration files
Live Trading


Installation-and-Setup

Creating a Virtual Environment
Installation/Setup
Requirements
Stopping Version 1
Installing and setting up Version 2
Configuration
Reboot startup
Manual startup


Identity

Identity


Configuration

Configuration
Configuration files
Location and file names
File contents
Order types
Examples for the CCXT framework
Examples for the OANDA framework


Orders

JackrabbitRelay Order Payloads
Payload Synopsis
Order Types
Actions
Examples


Conditional Orders

JackrabbitRelay Order Payloads
Oliver Twist: Jackrabbit Relay conditional and orphan order manager
Unveiling Oliver Twist's Conditional Methodology
Managing Orphan Orders: The Limit-Only Approach
The Literary Significance of "Oliver Twist"


Supported-Exchanges-and-Brokers

Supported Exchanges/Brokers
Forex Brokers
Confirmed working brokers
Cryptocurrency Exchanges
Confirmed working exchanges
Theoretically supported


Known-Issues

Known Issues
Closing a position fails
BitMex
Phemex
ByBit
Python 3.10
Kucoin Futures/TradingView


Virtual-Exchange-Broker-DSR

DSR (Duplicate Signal Remover)
Log Files


Jackrabbit-Mimic

Jackrabbit Mimic
Introduction
Usage
Data Source Integration
Simple Setup Process
Understanding Differences
Educational Focus
Setup and Configuration
Wallets and history
How cryptocurrency wallets work
Long positions
Short positions
Alert/Signal messages
Long positions
Short positions
Supporting Jackrabbit Mimic


Logs

Logs
Files
JackrabbitRelay
PlaceOrder


Testing-TradingView-connection

Testing TradingView connection
Testing method
Setup
DSR Testing
Force feeding payloads
Next Steps


Step-by-step guide to live trading with TradingView

Step-by-step guide to live trading with TradingView
Walk Through
Strategy Differences


Additional Programs

Additional Programs


Roadmap

Roadmap
Finished
In Progress
Future Plans


Supporting-Jackrabbit

Supporting Jackrabbit and it's future development
Current patrons and subscribers
The cost of open source
Supporting

Terms-and-Definitions

Terms and Definitions

Clone this wiki locally