Start by creating a project file that resides in your venv
folder. Then, point to the Python interpreter that resides in the venv
folder using the build configuration feature. These actions will allow you to run the correct Python interpreter for each virtual environment you create and not affect the configuration of other virtual environments, other project configurations, or your base configuration.
To set Geany up so that it runs Python code in the appropriate venv
, follow these steps:
1) Verify Geany is set up for Project Sessions. To do this, go to the main menu, select 'Edit', then 'Preferences'. The Preferences window will appear. Select the General Tab, then select 'Miscellaneous' tab. Now look at 'Projects' section on the tab. Verify both 'Use project-based session files' and 'Store project file inside the project-based directory' are selected.
2) Create a Geany project file in your venv
folder. To do this, go to the main menu, select 'Project', then select 'New'. Give the project a name and save it in your virtual environment folder.
3) Configure the build commands for the above project. To do this, go to the main menu, select 'Build', then select 'Set Build Commands'. A window will appear. Look for the 'Execute' button on the bottom left of the window. In the command box next to the 'Execute' button type in the complete path to the bin folder in your venv
folder that contains the Python interpreter you wish to run, then add "%f" to the end of the command. For example, my virtual folder is in home/my_virtual_env_folder
and I want to run the Python3.4 intrepreter in that folder, so I would type in:
/home/virtual_env_folder/bin/python3.4 "%f"
Click 'OK' and the changes you made will be saved. Now when you open the project you just created, the project file will automatically point to the correct Python interpreter for the venv
you are working in.