Setting up a virtualenv for blockly - OpenRoberta/openroberta-lab GitHub Wiki
The problem:
In a nutshell: blockly
needs python2.7.
Since an installation of python3+ is necessary for the lab and cross compilers, it can't be used directly with blockly.
The solution:
Setting up virtualenv
The easiest way is to install a virtualenv. Open the blockly
project and follow these steps:
- Install the python plugin für IntelliJ in File -> Settings -> Plugins:
- Shortcut: Ctrl + Alt + S
- Setup the project structure in File -> Project Structure -> Project Settings -> Project:
- Shortcut: Ctrl + Alt + Shift + S
- Add a new SDK, in case one is not available:
- In Add Python Interpreter window, select the following options:
- Virtualenv Environment
- Base interpreter: /usr/bin/python2.7
- Simply copy the above mentioned location and paste it into Base interpreter, instead of searching for it!
-
And that's it! IntelliJ will download virtualenv in the background. To test the installation, open a Terminal window:
- Shortcut: Alt + F12
- In an open Terminal window, click on +
-
When everything was setup correctly, (venv) will show up at the start of the command:
- With
python --version
the version of python being used can be checked - With
which python
the source of python can be verified
- With
deactivate
the virtualenv can be deactivated
- And by opening a new Terminal window the virtualenv is activated again
- With
Adding run configuration
Now a run configuration can be added to further ease building blockly. Following are the steps for the same:
- Click on Run -> Edit configurations or as follows:
- Add a new run configuration by clicking on Add new run configuration:
- Select Python from the dropdown:
- Enter the following particulars in the next window:
- Name: Build
- script: build.py
- Click on Apply and OK and that's it! Now the created run configuration will show up as follows:
By clicking on the configuration will be run, which in turn generates the blockly resources (compressed and messages).