innovationOUtside / tm351vm-binder

See if we can generate a Binder/repo2docker build of the TM351 VM
MIT License
7 stars 4 forks source link

psycopg2 not found #16

Open undercertainty opened 4 years ago

undercertainty commented 4 years ago

Notebook 08.1 raises the error with the cell:

# Run the database cleanup script

!./sql_initial_state.py

raises:

Traceback (most recent call last):
  File "./sql_initial_state.py", line 3, in <module>
    import psycopg2 as pg
ModuleNotFoundError: No module named 'psycopg2'

Problem with the PATH in the script perhaps? There's no problem with just doing import psycopg2 in a cell.

psychemedia commented 4 years ago

I haven't tested this yet but it raises an important question: I guess by default you are trying to run that script in a different python environment to the one in which everything was installed. So we maybe need to find a way to ensure that scripts are run in the correct environment by tweaking paths, or explicitly setting a hashbang at the start of the file?

psychemedia commented 4 years ago

@undercertainty Did you add a test case for this your test file? We should perhaps create a .tests/ dir to run build tests in that is then deleted in the final container or left hidden?

psychemedia commented 4 years ago

Simplest way to invoke it might be to run:

!python ./sql_initial_state.py or even better %run ./test.py. The latter will run in the same Python environment as the notebook kernel.

rather than !./sql_initial_state.py

undercertainty commented 4 years ago

Agree, I think that a test notebook that's called with %run would be better than a standalone python script.

Also easier for the students to see what's going on if they decide to look it up. The version I'm using at the moment attached here. Weirdly, GH doesn't allow notebooks to be attached, so I'm afraid it's zipped. reset_databases.zip

undercertainty commented 4 years ago

BTW, my online behaviour’s likely to be a bit odd for a bit ‘cos my Mac’s on the blink and I’m having to learn how to use my Windows machine for the first time.

From: Tony Hirst notifications@github.com Sent: 07 August 2020 16:40 To: innovationOUtside/tm351vm-binder tm351vm-binder@noreply.github.com Cc: undercertainty undercertainty@gmail.com; Mention mention@noreply.github.com Subject: Re: [innovationOUtside/tm351vm-binder] psycopg2 not found (#16)

@undercertainty https://github.com/undercertainty Did you add a test case for this your test file? We should perhaps create a .tests/ dir to run build tests in that is then deleted in the final container or left hidden?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/innovationOUtside/tm351vm-binder/issues/16#issuecomment-670578849 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ACAL4YU2NRAN3CO3VEHWVTTR7QN6HANCNFSM4NYRJJDQ .

psychemedia commented 4 years ago

@undercertainty Ah, good, we can maybe make some progress on debugging windows docker commands then:-) (I really should by myself a dev windows machines...)