Run backend locally

I was trying to run baserow locally through VScode.
I went through this doc docs/development/vscode-setup.md · develop · Baserow / baserow · GitLab and was able to run all the tests successfully. The frontend is up and working now.
when I command

python baserow/manage.py runserver --settings=config.settings.dev

I got always this erro ModuleNotFoundError: No module named ‘baserow’.

any help?

1 Like

Are you running it from the baserow/backend/src folder?

Hi @petrs ,
yes exactly. (baserow/backend/src).
and this is what I kept receiving as error.

any help would be appreciated.

Alright so it seems like you will need to add baserow source folders to your PYTHONPATH. So prefix your command like this:

BASEROW_DIR=/path/to/baserow/folder # your baserow repository
PYTHONPATH=$PYTHONPATH:$BASEROW_DIR/backend/src:$BASEROW_DIR/premium/backend/src:$BASEROW_DIR/enterprise/backend/src python baserow/manage.py runserver

Don’t forget to also set the DJANGO_SETTINGS_MODULE.

Many thanks @petrs.
it’s working now.
since it’s the first time that the backend runs locally, I got a warning as bellow:
"You have 254 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): auth, baserow_enterprise, baserow_premium, contenttypes, core, database, db, sessions, silk.
Run ‘python manage.py migrate’ to apply them. "

and I did run the “python manage.py migrate” then this error “redis.exceptions.ConnectionError: Error -3 connecting to redis:6379. Temporary failure in name resolution”.

seems Redis needs to be up. but redis is up and listening at port 6379.
below is the error message:

any help?

thanks in advance.

it’s running now.

But there is another problem I encountered. Although web-frontend and backend are running know, I got this error for fronend:


and this one for backend:

But in the console both backend and frontend are functional without any error message like below:

any idea?

For the backend, the page is correct, there is nothing at that URL. Try accessing the API docs at http://localhost:8000/api/redoc/ for instance. I think you backend is working.

With the front end problem, it seems that the app cannot access the backend because of some URL or resolution mismatch. Is your PUBLIC_BACKEND_URL defined correctly?

Thanks @petrs .
I did set the PUBLIC_BACKEND_URL. and still got the same error.
this is my launch.json on VScode:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: Debugging in Visual Studio Code
“version”: “0.2.0”,
“configurations”: [
{
“name”: “client: chrome”,
“type”: “chrome”,
“request”: “launch”,
“url”: “http://localhost:3000”,
“cwd”: “${workspaceFolder}/web-frontend”,
“webRoot”: “${workspaceFolder}/web-frontend”
},
{
“name”: “client: firefox”,
“type”: “firefox”,
“request”: “launch”,
“url”: “http://localhost:3000”,
// “cwd”: “${workspaceFolder}/web-frontend”,
“webRoot”: “${workspaceFolder}/web-frontend”
},
{
“name”: “backend: django”,
“type”: “python”,
“request”: “attach”,
“connect”: {
“host”: “localhost”,
“port”: 8000
},
“pathMappings”: [
{
“localRoot”: “${workspaceFolder}”,
“remoteRoot”: “/baserow”
}
]
},
{
“name”: “pytest coverage”,
“type”: “python”,
“request”: “launch”,
“module”: “pytest”,
“cwd”: “${workspaceFolder}”,
“args”: [
“-n=3”,
“–cov-report=xml:html_coverage/cov.xml”,
“–cov-config=${workspaceFolder}/backend/.coveragerc”,
“–cov=baserow”,
“backend/tests/”,
“premium/backend/tests/”,
“enterprise/backend/tests/”
],
“env”: {
“DATABASE_HOST”: “localhost”,
“PYTHONPATH”: “$PYTHONPATH:backend/src:premium/backend/src:enterprise/backend/src”,
“DJANGO_SETTINGS_MODULE”: “baserow.config.settings.dev”,
“BASEROW_PUBLIC_URL”: “http://localhost:3000”,
},
},
{
“name”: “vscode-jest-current-file”,
“type”: “node”,
“runtimeVersion”: “16.15.0”,
“request”: “launch”,
“cwd”: “${workspaceFolder}/web-frontend”,
“program”: “./node_modules/jest/bin/jest”,
“args”: [
“${fileBasename}”,
“–verbose”,
“-i”,
“–no-cache”
],
“env”: {
“PRIVATE_BACKEND_URL”: “http://localhost:8000
},
“console”: “integratedTerminal”,
“internalConsoleOptions”: “neverOpen”
},
{
“name”: “vscode-jest-tests”,
“type”: “node”,
“runtimeVersion”: “16.15.0”,
“request”: “launch”,
“console”: “integratedTerminal”,
“internalConsoleOptions”: “neverOpen”,
“cwd”: “${workspaceFolder}/web-frontend”,
“program”: “node_modules/.bin/jest”,
“args”: [
“–config=jest.config.js”,
“–runInBand”,
“–watchAll=false”,
],
“env”: {
“PRIVATE_BACKEND_URL”: “http://localhost:8000
},
},
]
}

and I’ve been struggling to connect the backend and frontend together and run them on VSCode for one week. :slightly_smiling_face:
But I cannot manage that so far.
Thanks for your help.

You didn’t set PUBLIC_BACKEND_URL.

However I guess the main problem is that you set BASEROW_PUBLIC_URL which you shouldn’t. So remove it from the env config.

Thanks @petrs.
I could not manage it to run on VSCode locally and think I would give up.
Thanks again for your help.