Odoo 18, the latest release of the software, is renowned for its robust functionality and effectiveness in streamlining business operations. This version is developed with Python 3.10+ for the backend, uses PostgreSQL as its database system, and relies on JavaScript for the frontend interface.
Ubuntu 20.04, a Long-Term Support (LTS) release, provides a stable environment with regular updates and security patches for five years. It also offers periodic updates for Linux kernel versions and graphics drivers, enhancing system performance and compatibility.
In this blog, we will guide you on How to Install Odoo 18 using the PyCharm IDE on Ubuntu 20.04
Prior to configuring PyCharm, it is crucial to install several essential libraries and packages required for running Odoo. Additionally, we'll cover the setup of PostgreSQL, configuring Python environments, and managing dependencies.
Let's dive into the details of these preliminary steps and ensure your system is fully prepared for Odoo development.
Step 1: Download and install the Pycharm IDE
We will be installing the PyCharm Community Edition, and it's important to ensure your machine meets certain basic requirements to run PyCharm smoothly.
The requirements for installing PyCharm on your computer are:
Requirement | Minimum | Recommended |
RAM | 4 GB of free RAM | 8 GB of total system RAM |
CPU | Any modern CPU | Multi-core CPU. PyCharm leverages multithreading for various operations and processes, allowing it to perform faster with an increased number of CPU cores. |
Disk Space | 3.5 GB | SSD drive with at least 5 GB of free space |
Monitor Resolution | 1024×768 | 1920×1080 |
Operating system | Officially released 64-bit versions of the following: Microsoft Windows 10 1809 or laterWindows Server 2019 or latermacOS 11.0 or laterAny Linux distribution that supports Gnome, KDE , or Unity DE.PyCharm is not available for the Linux distributions that do not include GLIBC 2.27 or later.Pre-release versions are not supported. | Latest 64-bit version of Windows, macOS, or Linux (for example, Debian, Ubuntu, or RHEL) |
You can install PyCharm by downloading the Debian installation file from the following URL:
PyCharm Community Edition Download
Alternatively, you can install PyCharm using the command line. To do this, open Terminal (you can press Ctrl + Alt + T to launch Terminal) and run the following commands:
sudo apt-get update
sudo apt-get upgrade
sudo snap install pycharm-community --classic
Step 2: Installing Python 3.12
The latest version of Python 3.12 isn’t available in the default Ubuntu repositories. To install it, we’ll need to add an alternative repository. The deadsnakes repository on Launchpad contains various Python packages, including Python 3.12.
To add the deadsnakes repository, use the following commands:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
You can verify the updated list of Python packages using the following command.
apt list | grep python3.12
You can install Python 3.12 by running the following command:
sudo apt-get install python3.12
To install the necessary packages for Python 3, you can use the following code:
sudo apt-get install python3.12-dev build-essential libjpeg-dev libpq-dev libjpeg8-dev libxml2-dev libssl-dev libffi-dev libmysqlclient-dev libxslt1-dev zlib1g-dev libsasl2-dev libldap2-dev liblcms2-dev
Step 3: Install Web Dependencies
The next step involves installing the necessary web dependencies.
sudo apt-get install -y npm
sudo ln -s /usr/bin/nodejs/usr/bin/node
sudo npm install -g less less-plugin-clean-css
sudo apt-get install -y node-less
Step 4: Install Wkhtmltopdf
To generate Odoo reports, Wkhtmltopdf needs to be installed. You can do this by running the following command:
sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
Step 5: Install PostgreSQL
The next step is to install PostgreSQL:
sudo apt install postgresql postgresql-client
Step 6: Configure a Database User Role for Odoo Databases
Create a new database user by following these instructions. Be sure to set a password for this user, as you'll need it when creating the configuration file, so keep it saved.
sudo su - postgres
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo18
Next, grant superuser privileges to the specified user.
psql
ALTER USER odoo18 WITH SUPERUSER;
Finally, exit both psql and the Postgres user.
\q
exit
Step 7: Obtain Odoo 18 Source Code
You can acquire the Odoo 18 Community Source code directly from Odoo's GitHub repository. Alternatively, you can clone it using Git. First, install Git by running the following command:
sudo apt-get install git
Then, use the command below to clone the Odoo code into an ‘odoo18’ directory within your home directory:
git clone https://www.github.com/odoo/odoo --depth 1 --branch 18.0 --single-branch odoo18
Step 8: Open the Odoo Project in PyCharm
Launch PyCharm Community Edition and navigate to the ‘Odoo18’ directory. Once the project is open, you might see a dialogue box similar to the one shown below. This is for creating a virtual environment; however, we'll set up the virtual environment via the terminal, so go ahead and cancel it.
To open the terminal, either click on the icon displayed below or use the shortcut Alt+F12.
Next, run the following commands to create a virtual environment using Python 3.12.
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.12
sudo apt install python3.12-venv
python3.12 -m venv your_venv_name
After closing and reopening the terminal, you’ll notice that your virtual environment is active. The terminal will display an indicator with the name of your virtual environment, as shown below:
If your virtual environment doesn’t activate automatically, use the following command.
source your_venv_name/bin/activate
Step 9: Install Required Python Packages
Odoo depends on several Python packages listed in the require file located in the ‘odoo18’ directory. To install these packages, execute the following command in the terminal:
pip install -r requirements.txt
If no errors occur, you can use the following command to verify that all the dependencies listed in requirements.txt have been successfully installed.
pip list
If you encounter any errors, open the requirements.txt file and install each dependency individually using the following command.
pip install requirement_name
Example 1:
Example 2:
In most cases, when installing packages listed twice, only one needs to be installed. So, if one fails to install, it usually isn’t an issue.
Additionally, if prerequisites defined with sys_platform as 'win32' fail to install, you can skip them.
If errors arise while installing the package "psycopg2==2.9.2 ; sys_platform != 'win32' and python_version <= '3.10' or psycopg2==2.9.5 ; python_version > '3.10' or sys_platform == 'win32'", use the following command to install an alternative package instead.
pip install psycopg2-binary
Step 10: Create the odoo.conf File in the odoo18 Directory
To create the configuration file, right-click the Odoo18 directory and select New -> File -> odoo.conf.
After creating the odoo.conf file, insert the following block of code, and make sure to update the db_password field with the password you set for the Odoo18 database user in the previous step.
[options]
admin_passwd = admin
db_host = localhost
db_port = 5432
db_user = odoo18
db_password = your_password
addons_path = /home/user/odoo18/addons
xmlrpc_port = 8018
Additionally, update the addons_path value with the actual path to the Odoo18 addons directory. You can obtain this path by navigating to the addons directory and pressing Ctrl + Shift + C. This will copy the current directory path, which you can then replace in the addons_path field. If you create a new directory for your custom modules, be sure to include its path in the addons_path, separated by commas.
eg: addons_path = /home/user/odoo/addons, /home/user/odoo/custom_addons
Step 11: Add Python Interpreter
To configure a Python interpreter, navigate to Settings -> Project: odoo18 -> Python Interpreter.
When you open the specified window, if the interpreter (Python 3.12 from the odoo18 virtual environment) is already configured, no changes are needed. Otherwise, choose the Add Interpreter option and proceed with the following selections.
Step 12: Configure the Project in PyCharm
To set up the project configuration, click Edit Configurations under Current File.
When the dialogue box appears, click the "+" button and choose "Python" from the list.
Then, fill in the fields as shown in the image below.
Name: You can assign any name to this configuration.
Python Interpreter: This field should include the Python interpreter for this project. Since we set up the interpreter in the previous step, it should populate automatically.
Script Path: Select the odoo-bin file located in the odoo18 directory.
Parameters: You can add parameters here to run with the script; the -c parameter is required. You may also need to include the configuration file as a parameter.
Working Directory: Specify the path to the project's current working directory here.
Step 13: Test Run Odoo 18
The Odoo setup is complete. You can now test it by clicking the button below to launch the project.
You can now test your setup by navigating to localhost:8018 in your browser. If all your configurations are correct, the browser will open the Odoo database management page, as shown below.
This is the process for setting up an Odoo 18 development environment in PyCharm on Ubuntu 22.04.
To read more about How to Setup Odoo 17 Development Environment Using Pycharm in Ubuntu 22.04, refer to our blog How to Setup Odoo 17 Development Environment Using Pycharm in Ubuntu 22.04.