Running locally causes an error: No module named 'imp'

Hi,

I am trying to get my code running on a local instance of Anvil and it is failing.

I am so new to this it is probably something daft I have done.

I’ve been wrestling with a portable class definition in an included module this afternoon without any grace I fear.

I got it all working in the ANVIL IDE to the point where it complained the server was taking too long so I committed it to GitHub and pulled it down to my local instance.

Anvil websocket open
[INFO  anvil.executors.downlink] Downlink client connected with spec {:runtime "python3-full", :session_id "vfXhOcnZOhgSlydXJ0cR"}
Downlink authenticated OK
Calling function 'GetRSASIFTER' for app 'kpi_tool_for_the_rsa' (ID server-39vaXXB3Wu8O/A==)
[DEBUG anvil.app-server.run] [CLIENT] Client year 2023
Client month 1
Traceback (most recent call last):
  File "<frozen runpy>", line 189, in _run_module_as_main
  File "<frozen runpy>", line 112, in _get_module_details
  File "C:\Python\Lib\site-packages\anvil_downlink_worker\__init__.py", line 2, in <module>
    import ast, sys, imp, importlib
ModuleNotFoundError: No module named 'imp'
Server code exited unexpectedly: 35bca0510b (IDs server-39vaXXB3Wu8O/A==)
Worker terminated for IDs {'server-39vaXXB3Wu8O/A=='} (return code None)
[ERROR anvil.app-server.run] Error report from client code:
anvil.server.ExecutionTerminatedError: Server code exited unexpectedly: 35bca0510b
Traceback:
  app/KPI_Tool_for_the_RSA/RSAKPI/__init__.py:28

I could not find reference to a missing ‘imp’ in the search I did here.

All nudges welcome.

Thanks

Adrian

imp was removed in python 3.12, I don’t think the anvil server states it will run on 3.12?

You will need to install a virtual environment for something like python 3.10 and start it from inside the virtual environment.

1 Like

Hi Ian,

Ah OK I have too new a version installed on my VM then.

I’ve yet to get to the page on Python virtual environments*, I’ll uninstall 3.12 and install 3.10, then reinstall Anvil etc.

Thanks
Adrian

*Once I can handle one installation, I’ll move to multiple.

Hi Ian,

I imported sys and platform and checked the server side version and found:

print("Python Server Version = " + sys.version)

Python Server Version = 3.10.12 (main, Jun 13 2023, 15:41:19) [GCC 10.2.1 20210110]

I’ll get that now.

Thanks for the nudge.

Adrian

2 Likes