aws-elastic-beanstalk-cli-setup: Compatibility with Python 3.12, ModuleNotFoundError: No module named 'imp'

eb tool broken after upgrade to python 3.12 due to imp module remotion (https://github.com/python/cpython/issues/98040)

Stacktrace:

Traceback (most recent call last):
  File "/home/dmt/.ebcli-virtual-env/bin/eb", line 5, in <module>
    from ebcli.core.ebcore import main
  File "/home/dmt/.ebcli-virtual-env/lib/python3.12/site-packages/ebcli/core/ebcore.py", line 16, in <module>
    from cement.core import foundation, handler, hook
  File "/home/dmt/.ebcli-virtual-env/lib/python3.12/site-packages/cement/core/foundation.py", line 11, in <module>
    from ..core import output, extension, arg, controller, meta, cache, mail
  File "/home/dmt/.ebcli-virtual-env/lib/python3.12/site-packages/cement/core/extension.py", line 8, in <module>
    from imp import reload  # pragma: no cover
    ^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'imp'

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 29
  • Comments: 21 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Hi! I have the same problem on Python 3.12.4. The AWS documentation shows version 3.11 or later . https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install-advanced.html Let’s put the reactions of those who are facing the same problem on python 3.12.4.

already solved!, just downgrade your python with version Python 3.11.7 and Pip version pip 23.2.1

Just ran into this. Devs., please update things so that it works on Python 3.12. The latest Ubuntu installs Python 3.12

This is fixed now. EB CLI >= 3.21.0 works with Python 3.12

At the very least this repo’s readme needs to be updated to clarify that python 3.12+ should NOT be used. This shouldn’t take too long…

I don’t get this - i thought the whole point of using python virtual environments is that you could specify a version of python to use. Why is it necessary to downgrade python when your installer is using a virtual environment to begin with? I can’t deploy my website right now because the person who set it up, created the deploy script using this ebcli tool and the tool won’t work on a newly upgraded machine because of this ‘imp’ package. I see a thread on the tool’s repository that it was already addressed and fixed back in February. So is this installer installing an older version of ebcli than the current one? I wish someone at AWS would address this as it’s very difficult to rely on amazon tools such as elastic beanstalk when the primary tool many developers are using in conjunction with it is broken and the only suggested fix is ‘change your php version back to something already out-of-date’ And this ticket is already 8 months old, and it’s still broken? wth aws??

if you are using windows 11 and python 3.12, i found that this works for me, hoping it helps someone else

check py.exe on your system

~\dev  on ⛅ (Seoul)
PS > get-command py

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     py.exe                                             3.12.2150… C:\Users\hdformat\AppData\Local\Programs…

check pythons on your system

~\dev  on ⛅ (Seoul)
PS > py --list

 -V:3.12 *        Python 3.12 (64-bit)

install python 3.11 from dowloading a installer on python official site

https://www.python.org/downloads/release/python-3117/

check pythons again after

~\dev  on ⛅ (Seoul)
PS > py --list
 -V:3.12 *        Python 3.12 (64-bit)
 -V:3.11          Python 3.11 (64-bit)

run eb-cli installer using python 3.11

~\dev  on ⛅ (Seoul) took 3s
PS > py -3.11 .\aws-elastic-beanstalk-cli-setup\scripts\ebcli_installer.py

***********************************
1. Locating virtualenv installation
***********************************
...
***************
6. Finishing up
***************
Success!

EBCLI has been installed.

run eb cli

~\dev  on ⛅ (Seoul) took 10s
PS > eb --help
usage: eb (sub-commands ...) [options ...] {arguments ...}

Welcome to the Elastic Beanstalk Command Line Interface (EB CLI).
For more information on a specific command, type "eb {cmd} --help".

commands:
  abort        Cancels an environment update or deployment.
  appversion   Listing and managing application versions
  clone        Clones an environment.
  codesource   Configures the code source for the EB CLI to use by default.
  config       Modify an environment's configuration. Use subcommands to manage saved configurations.
  console      Opens the environment in the AWS Elastic Beanstalk Management Console.
  create       Creates a new environment.
  deploy       Deploys your source code to the environment.
  events       Gets recent events.
  health       Shows detailed environment health.
  init         Initializes your directory with the EB CLI. Creates the application.
  labs         Extra experimental commands.
  list         Lists all environments.
  local        Runs commands on your local machine.
  logs         Gets recent logs.
  open         Opens the application URL in a browser.
  platform     Commands for managing platforms.
  printenv     Shows the environment variables.
  restore      Restores a terminated environment.
  scale        Changes the number of running instances.
  setenv       Sets environment variables.
  ssh          Opens the SSH client to connect to an instance.
  status       Gets environment information and status.
  swap         Swaps two environment CNAMEs with each other.
  tags         Allows adding, deleting, updating, and listing of environment tags.
  terminate    Terminates the environment.
  upgrade      Updates the environment to the most recent platform version.
  use          Sets default environment.

options:
  -h, --help            show this help message and exit
  --debug               toggle debug output
  --quiet               suppress all output
  -v, --verbose         toggle verbose output
  --profile PROFILE     use a specific profile from your credential file
  -r REGION, --region REGION
                        use a specific region
  --no-verify-ssl       don't verify AWS SSL certificates
  --version             show application/version info

To get started type "eb init". Then type "eb create" and "eb open"