B4J Question [Solved] Python installation

udg

Expert
Licensed User
Longtime User
In the long run, will it be advisable to install a full Python enviroment on our development system or we should rely on the one embedded in B4J?

Similar question arises for a remote VPS server. Install Python once (adding libraries specific to running projects) or leaving each Jserver+PyBridge project with its own copy of the enviroment?

My impression is that PyBridge will be a quantum leap for us, opening the door for new, fantastic opportunities. So any advice that shows how to setup things in the "better" way will be welcome. Well, "better" related to heavy usage rather than occasional.

TIA
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
They Python package included with B4J is a full package.
You should have a "global" Python, configured under Tools - Configure Paths. You can copy the folder from C:\Program Files\Anywhere Software\B4J\Libraries\Python.
Use a local (project specific) Python when you want to distribute an app with an embedded Python.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
1. Ok, so on dev machine I setup my global Python copying it from the installation of B4H 10.20+
2. Preparing an EXE to distribute -> use local Python
3. Given 1 & 2 above, when for a project I add a Python lib, should I add to both enviroments?
4. What about a VPS? Should I install from the OS repository a Python "package" and add needed libs to it?
5. Given 4 above, a Jserver+PyBridge will be directed to use the global Python active in the server (so, no embedded local py in jar)?

Sorry for so many questions, but I'd like to start in the right way with a "definitive" setup (then forget about it).
Meanwhile W3Schools lessons are useful to learn the basics and in no time be able to read not too compact code
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Two main cases:

1. You intend to distribute a standalone package with embedded Python.
2. You don't intent to include an embedded Python.

For 1, you should work with a local Python and install libraries to the local Python. Note that if you are using large libraries (pytorch for example) then it is probably better not to distribute it yourself.
For 2, both options possible. I would start with the global Python.

4. With a VPS you will run with an external Python. You can install dependencies in the default Python. The other option is to use a feature of Python named virtual environment venv. It lets you keep a more isolated environment. I think that for most cases, installing in the default Python is good enough.

5. jServer + PyBridge, is the same as #4.
 
  • Like
Reactions: udg
Upvote 0
Top