HHS / simpler-grants-pdf-builder

PDF builder that's used by the SimplerNOFOs project, part of the Simpler Grants initiative at HHS.
4 stars 1 forks source link

Issue in setting up local enviornment and running it locally #7

Open umeshkarthik opened 6 months ago

umeshkarthik commented 6 months ago

We were trying to setup the application running locally PS Y:\simpler-grants-pdf-builder\bloom_nofos> poetry run start Getting the below error

ModuleNotFoundError: No module named 'environ'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "Y:\simpler-grants-pdf-builder\bloom_nofos\manage.py", line 22, in main() File "Y:\simpler-grants-pdf-builder\bloom_nofos\manage.py", line 18, in main execute_from_command_line(sys.argv) File "C:\Users\ukrajeswaran\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\core\management__init.py", line 442, in execute_from_command_line utility.execute() File "C:\Users\ukrajeswaran\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\core\management__init.py", line 436, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Users\ukrajeswaran\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\core\management\base.py", line 426, in run_from_argv connections.close_all() File "C:\Users\ukrajeswaran\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\utils\connection.py", line 84, in close_all for conn in self.all(initialized_only=True): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ukrajeswaran\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\utils\connection.py", line 76, in all return [ ^ File "C:\Users\ukrajeswaran\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\utils\connection.py", line 73, in iter__ return iter(self.settings) ^^^^^^^^^^^^^ File "C:\Users\ukrajeswaran\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\utils\functional.py", line 47, in get res = instance.dict[self.name] = self.func(instance) ^^^^^^^^^^^^^^^^^^^ File "C:\Users\ukrajeswaran\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\utils\connection.py", line 45, in settings self._settings = self.configure_settings(self._settings) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ukrajeswaran\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\db\utils.py", line 148, in configure_settings databases = super().configure_settings(databases) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ukrajeswaran\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\utils\connection.py", line 50, in configure_settings settings = getattr(django_settings, self.settings_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ukrajeswaran\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\conf\init.py", line 89, in getattr self._setup(name) File "C:\Users\ukrajeswaran\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\conf\init.py", line 76, in _setup self._wrapped = Settings(settings_module) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ukrajeswaran\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\django\conf\init.py", line 190, in init mod = importlib.import_module(self.SETTINGS_MODULE) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64qbz5n2kfra8p0\Lib\importlib__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1204, in _gcd_import File "", line 1176, in _find_and_load File "", line 1147, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "Y:\simpler-grants-pdf-builder\bloom_nofos\bloom_nofos\settings.py", line 16, in import environ ^^^^^^^^^^^^^^ ModuleNotFoundError: No module named 'environ'

pcraig3 commented 6 months ago

~Hello! Sorry about that, it must be that I have environ installed globally so I didn't notice that it wasn't in the pyproject.toml file.~

environ is used in the settings.py file to import env vars. You should be able to use the default environment variables to get everything booted up in dev mode.

This refers to the django-environ package, which is included as one of the deps in the pyproject.toml file. Once you use poetry install, it should be available to you.

Let me know if you have any other problems!

umeshkarthik commented 6 months ago

Hi There, I followed the exact same step as per the instruction below. Installed the dhango-env still getting the error"No module named 'environ" [image: image.png]

On Tue, May 14, 2024 at 4:20 PM Paul Craig @.***> wrote:

Hello! Sorry about that, it must be that I have environ installed globally so I didn't notice that it wasn't in the pyproject.toml file.

environ is used in the settings.py https://github.com/HHS/simpler-grants-pdf-builder/blob/main/bloom_nofos/bloom_nofos/settings.py#L16 file to import env vars. You should be able to use the default environment variables to get everything booted up in dev mode.

Let me know if you have any other problems!

— Reply to this email directly, view it on GitHub https://github.com/HHS/simpler-grants-pdf-builder/issues/7#issuecomment-2111073787, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGTOCEC6QE225UOOEJYS7Q3ZCJW2PAVCNFSM6AAAAABHWVXV2GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJRGA3TGNZYG4 . You are receiving this because you authored the thread.Message ID: @.***>

pcraig3 commented 6 months ago

Okay, I'll do a clean install of this today and see if I can replicate this and fix it. Will update the issue when I do.

umeshkarthik commented 6 months ago

Hi Paul, Thank you for your swift response. Also, do you know if this application is publically hosted somewhere for testing purposes? If so can you please share those information with us?

Thanks Umesh K

On Wed, May 15, 2024 at 9:39 AM Paul Craig @.***> wrote:

Okay, I'll do a clean install of this today and see if I can replicate this and fix it. Will update the issue when I do.

— Reply to this email directly, view it on GitHub https://github.com/HHS/simpler-grants-pdf-builder/issues/7#issuecomment-2112566872, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGTOCEBVTWM4ARHVAEUDF23ZCNQRZAVCNFSM6AAAAABHWVXV2GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJSGU3DMOBXGI . You are receiving this because you authored the thread.Message ID: @.***>

pcraig3 commented 6 months ago

Hi there!

first time setup

I just ran through a clean install on my local environment and updated the README to make the first time setup clearer.

The main change I added is that you need to copy the .env.example file to be a .env file in the bloom_nofos/bloom_nofos folder.

I also added the migration step that you'll need the first time the app is run.

environ missing

I must admit I am confused about this one. Using poetry, you should be able to:

You should also run the migrations but that's all I need to get the app booted up the first time.

import environ in bloom_nofos/bloom_nofos/settings.py actually refers to the django-environ package, which was already in the pyproject.toml file.

Poetry manages your virtualenv for you, so once you do poetry install, you should have all the packages available to you (including django-environ) once you later run poetry run start or poetry run python manage.py runserver. I can't think of a reason why it wouldn't be there.

All I can say is that it worked for me on my Mac. It could be to do with you being on a Windows computer, but I didn't see anything in the issues in the GitHub repo or on Google about Windows causing a problem with django-environ.

could I share the application?

At this time, the NOFO Builder is an internal tool we are using as part of our work with the Health and Human Services department. If you are within the department, we would be happy to follow up about this, but otherwise I'm afraid I can't share the hosting information.

umeshkarthik commented 6 months ago

Hi Paul, Thank you for your email. I work as a contractor for HRSA OP-Division. We are trying to set it up on the Windows machine and we still have the same issue after following your updated instructions. Please let us know if there is any way we can get access to the hosted site.

Thanks Umesh K

On Wed, May 15, 2024 at 1:11 PM Paul Craig @.***> wrote:

Hi there! first time setup

I just ran through a clean install on my local environment and updated the README https://github.com/HHS/simpler-grants-pdf-builder/commit/fc3f2bf39c18a1caa41ec4c7cc5d3eddf91551cf to make the first time setup clearer.

The main thing is that you need to copy the .env.example file to be a .env file in the bloom_nofos/bloom_nofos folder.

I also added the migration step that you'll need the first time the app is run. environ missing

I must admit I am confused about this one. Using poetry, you should be able to:

  • clone the repo
  • cd into the main folder
  • poetry install
  • create .env file
  • cd bloom_nofos
  • poetry run start

You should also run the migrations but that's all I need to get the app booted up the first time.

import environ in the settings actually refers to the django-environ https://pypi.org/project/django-environ/ package, and it was already in the poetry lockfile. Poetry should manage your virtualenv for you, so if you are using poetry run start or poetry run python manage.py runserver, the django-environ package should be in your virtualenv.

All I can say is that it worked for me on my Mac. It could be to do with you being on a Windows computer, but I didn't see anything on the github repo or on Google about Windows having a problem with django-environ. could I share the application

At this time, the NOFO Builder is an internal tool we are using as part of our work with the Health and Human Services department. If you are within the department, we would be happy to follow up about this, but otherwise I'm afraid I can't share the hosting information.

— Reply to this email directly, view it on GitHub https://github.com/HHS/simpler-grants-pdf-builder/issues/7#issuecomment-2113055038, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGTOCECLOQRR6P4BFYBRZWDZCOJMRAVCNFSM6AAAAABHWVXV2GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJTGA2TKMBTHA . You are receiving this because you authored the thread.Message ID: @.***>

apeterson-dmigs commented 6 months ago

hi paul, i have also been trying to run this service, and i got the server to successfully run. however, i am unsure if it is running in production mode or not. furthermore, if i want to create an account for this, there are no options on the site itself. this it what it looks like:

Screenshot 2024-05-16 152026

in this photo, there is no option to let me sign up and add an account. what is the workaround for this issue?

pcraig3 commented 6 months ago

Hi @apeterson-dmigs,

Glad to see you got it running. Not addressing how users are created/managed was an oversight in the documentation.

I just pushed an update to the README that explains how to create a superuser account from the command line. (Here's a Django tutorial that explains more about the superuser creation process). Once you have created a user account, you will be able to log in and add more accounts using the admin backend at localhost:8000/admin

The other thing you are likely to need is a NOFO template, unless you already have one. I am not sure how to proceed on this matter — I can't provide one unless you send a formal request through an official channel.