Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running in PyCharm , error saying env variables not declared #51

Open
dosapati opened this issue Oct 9, 2023 · 2 comments
Open

Running in PyCharm , error saying env variables not declared #51

dosapati opened this issue Oct 9, 2023 · 2 comments

Comments

@dosapati
Copy link

dosapati commented Oct 9, 2023

Setting up backend code in Pycharm to run locally and running into settings error, even after setting .env file....while running make migrate

make migrate
echo "Running migrations."
Running migrations.
docker compose create db
[+] Building 0.0s (0/0) docker:desktop-linux
[+] Creating 1/0
✔ Container backend-db-1 Running 0.0s
docker compose start db
poetry run python -m alembic upgrade head
Traceback (most recent call last):
File "anaconda3/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "anaconda3/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "Library/Caches/pypoetry/virtualenvs/llama-app-backend-5r6C9Q_F-py3.10/lib/python3.10/site-packages/alembic/main.py", line 4, in
main(prog="alembic")
File "Library/Caches/pypoetry/virtualenvs/llama-app-backend-5r6C9Q_F-py3.10/lib/python3.10/site-packages/alembic/config.py", line 630, in main
CommandLine(prog=prog).main(argv=argv)
File "Library/Caches/pypoetry/virtualenvs/llama-app-backend-5r6C9Q_F-py3.10/lib/python3.10/site-packages/alembic/config.py", line 624, in main
self.run_cmd(cfg, options)
File "Library/Caches/pypoetry/virtualenvs/llama-app-backend-5r6C9Q_F-py3.10/lib/python3.10/site-packages/alembic/config.py", line 601, in run_cmd
fn(
File "Library/Caches/pypoetry/virtualenvs/llama-app-backend-5r6C9Q_F-py3.10/lib/python3.10/site-packages/alembic/command.py", line 385, in upgrade
script.run_env()
File "Library/Caches/pypoetry/virtualenvs/llama-app-backend-5r6C9Q_F-py3.10/lib/python3.10/site-packages/alembic/script/base.py", line 578, in run_env
util.load_python_file(self.dir, "env.py")
File "Library/Caches/pypoetry/virtualenvs/llama-app-backend-5r6C9Q_F-py3.10/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 93, in load_python_file
module = load_module_py(module_id, path)
File "Library/Caches/pypoetry/virtualenvs/llama-app-backend-5r6C9Q_F-py3.10/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 109, in load_module_py
spec.loader.exec_module(module) # type: ignore
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "Developer/react/sec-insights/backend/alembic/env.py", line 9, in
from app.core.config import settings
File "Developer/react/sec-insights/backend/./app/core/config.py", line 171, in
settings = Settings()
File "pydantic/env_settings.py", line 40, in pydantic.env_settings.BaseSettings.init
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.init
pydantic.error_wrappers.ValidationError: 8 validation errors for Settings
OPENAI_API_KEY
field required (type=value_error.missing)
AWS_KEY
field required (type=value_error.missing)
AWS_SECRET
field required (type=value_error.missing)
POLYGON_IO_API_KEY
field required (type=value_error.missing)
DATABASE_URL
field required (type=value_error.missing)
S3_BUCKET_NAME
field required (type=value_error.missing)
S3_ASSET_BUCKET_NAME
field required (type=value_error.missing)
CDN_BASE_URL
field required (type=value_error.missing)
make: *** [migrate] Error 1

@sourabhdesai
Copy link
Contributor

@dosapati you need to load in the .env file before being able to run most of the make commands. See step 5 in the backend's setup instructions:

  1. Create the .env file and source it. The .env.development file is a good template.
    cp .env.development .env
    set -a
    source .env

@sourabhdesai
Copy link
Contributor

Thanks for your question! I just created a troubleshooting.md file where this problem + solution is now documented:

https://github.com/run-llama/sec-insights/blob/main/backend/troubleshooting.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants