Virtual Environment
This section applies only to pip
installs. Docker based installs eliminate such environment issues, and are therefore worth a look.
Important: in addition to Python environment, there are other configuration settings to consider as described in the Quick Start.
Per-project venv
You created a virtual environment when you installed ApiLogicServer. This venv
will work for all of your created ApiLogicServer projects, or you can use a per-project venv
, as follows.
The created project contains a requirements.txt
used to create a virtual environment.
You can create it in the usual manner:
cd ApiLogicProject
python3 -m venv venv # may require python -m venv venv
source venv/bin/activate # windows venv\Scripts\activate
python3 -m pip install -r requirements.txt
Shared venv
VSCode users may wish to share a venv
over multiple projects. Two altermnatives are described below.
From Create (default)
Projects created starting with version 10.0.8 (see preview) have a preset python.defaultInterpreterPath
in .vscode/settings.json
. The Python interpreter used to create the project (i.e, your ApiLogicServer install location) will be the default interpreter / venv. Note this only takes effect when you start VSCode; you can override in manually.
Show me how
From Settings
Use Settings > Python: Venv Path, and specify a directory containing venv
directories (e.g, where you installed API Logic Server). This is a convenient way to get started.
Recall this does not apply to docker or Codespace environments.
A typical way to install API Logic Server is to create a directory called ApiLogicServer
, and create a venv
inside it, like this:
python -m venv venv # may require python3 -m venv venv
venv\Scripts\activate # mac/linux: source venv/bin/activate
python -m pip install ApiLogicServer
The resultant directory structure:
This venv
can be re-used by defining a global path in your Python: venv
setting:
Then, choose this venv
with select interpreter
(you sometimes have to open a Python file):
From Environmental Variable
You can also set up the default venv
for VSCode. For example, if you installed ApiLogicServer in /dev/ApiLogicServer
:
venv_setup
- shortcut setup procedures
Ss of release 5.02.10, projects are created with a venv_setup
directory which may be helpful in establishing and verifying your Python environment. For more information, see the Trouble Shooting Guide.
venv
Troubleshooting
By far, most of the support calls we get involve venv
setup.
To find more information, please click here.
Notes
Issues with pip
The install sometimes fails due on machines with an older version of pip
. If you see a message suggesting you upgrade pip
, do so.
VSCode may fail to find your venv
If VSCode does not find your venv
, you can specify it manually using Python: Select Interpreter
For more information, see Work with Environments.
Copy Not Recommended
Recommend re-creating a venv rather than moving/copying; for more information, see here.