Installation
This section covers the installation process for the V2ROOT library on both Linux and Windows platforms.
Prerequisites
Before installing V2ROOT, ensure you have the following:
Python 3.6 or higher: V2ROOT requires Python 3.6 or later. You can check your Python version with:
python3 --versionV2Ray: V2ROOT relies on the V2Ray core to function. This should already be installed and properly configured on your system.
Installing V2ROOT
V2ROOT can be easily installed using pip on both Linux and Windows.
Windows Installation
On Windows, assuming all prerequisites (like V2Ray and required DLLs) are already installed, simply install V2ROOT using pip:
pip install v2root
This will download and install the V2ROOT package along with its dependencies (e.g., colorama for colored terminal output).
Linux Installation
On Linux, you can also install V2ROOT using pip:
pip install v2root
However, since V2ROOT relies on the V2Ray core, you may encounter issues if V2Ray is not properly installed or configured. If you run into errors (e.g., the “General Failure” error with code -1), follow the troubleshooting steps below.
Troubleshooting on Linux
If you encounter the error Connection test failed: General failure (e.g., file operation failed, fork failed, or system command error) (error code -1), it typically means V2ROOT cannot find or execute the V2Ray core. Follow these steps to resolve the issue:
Check the V2Ray Executable Path:
V2ROOT expects the V2Ray executable (
v2ray) to be located in thelib/directory of the package, typically at:/home/<your-username>/.local/lib/python3.10/site-packages/v2root/lib/v2ray
Verify that the
v2rayexecutable exists and is executable:ls -l /home/<your-username>/.local/lib/python3.10/site-packages/v2root/lib/v2ray
If the file is missing or not executable, you’ll need to place the V2Ray core there. Proceed to the next step.
Manually Download and Place the V2Ray Core:
If the V2Ray executable is missing or not functional, download it manually:
wget https://github.com/v2fly/v2ray-core/releases/download/v5.15.1/v2ray-linux-64.zip unzip v2ray-linux-64.zip -d /tmp/v2ray cp /tmp/v2ray/v2ray /home/<your-username>/.local/lib/python3.10/site-packages/v2root/lib/v2ray chmod +x /home/<your-username>/.local/lib/python3.10/site-packages/v2root/lib/v2ray
Replace
<your-username>with your actual username.Test the V2Ray Core:
Verify that the V2Ray core is functional by running:
/home/<your-username>/.local/lib/python3.10/site-packages/v2root/lib/v2ray versionIf this command outputs the V2Ray version (e.g.,
V2Ray 5.15.1), the core is working correctly. If you get an error, check for missing dependencies:ldd /home/<your-username>/.local/lib/python3.10/site-packages/v2root/lib/v2rayIf any libraries are missing (e.g.,
libjansson.soorlibssl.so), install them:sudo apt install -y libjansson-dev libssl-dev
Verify Installation:
After resolving any issues, test that V2ROOT can initialize properly by running a simple script:
from v2root import V2ROOT client = V2ROOT() print("V2ROOT initialized successfully!")
If you still encounter errors, check the V2Ray logs for more details. The log files are created in the same directory as the script you are running. For example, if you run a script named
my_script.py, the logs will be created asv2ray_service.log,v2ray.log, andv2ray_err.login the same directory asmy_script.py. You can view them with:cat v2root.log