trek10inc / awsume

A utility for easily assuming AWS IAM roles from the command line.
https://awsu.me
MIT License
485 stars 90 forks source link

Can't get past the alias/sourcing error. #238

Open matale opened 8 months ago

matale commented 8 months ago

Have Python setup using asdf on an Intel Mac.

Did the awsume installation.

Running awsume command I get.

Warning: the awsume shell script is not being sourced, please use awsume-configure to install the alias
Awsume error: Profile default not found.
/Users/roman/.asdf/installs/python/3.12.0/bin/awsume: line 183: return: can only `return' from a function or sourced script

Running awsume-configure I get:

Traceback (most recent call last):
  File "/Users/roman/.asdf/installs/python/3.12.0/bin/awsume-configure", line 5, in <module>
    from awsume.configure.main import main
  File "/Users/roman/.asdf/installs/python/3.12.0/lib/python3.12/site-packages/awsume/configure/__init__.py", line 1, in <module>
    from awsume.configure import alias
  File "/Users/roman/.asdf/installs/python/3.12.0/lib/python3.12/site-packages/awsume/configure/alias.py", line 2, in <module>
    from distutils.spawn import find_executable
ModuleNotFoundError: No module named 'distutils'

I have also tried manually adding alias awsume=". awsume" to my .zshrc file still get the first error.

thisKeeWord commented 8 months ago

Also encountering the issue

fauzanelka commented 7 months ago
alias awsume=". $(asdf which awsume)"
sethwrowan commented 7 months ago

I was also having this issue when I attempt to run awsume-configure after installing Awsume with Homebrew.

 ~ awsume-configure                                                                                                                                 1 ✘  14:17:57
Traceback (most recent call last):
  File "/opt/homebrew/bin/awsume-configure", line 5, in <module>
    from awsume.configure.main import main
  File "/opt/homebrew/Cellar/awsume/4.5.3_3/libexec/lib/python3.12/site-packages/awsume/configure/__init__.py", line 1, in <module>
    from awsume.configure import alias
  File "/opt/homebrew/Cellar/awsume/4.5.3_3/libexec/lib/python3.12/site-packages/awsume/configure/alias.py", line 2, in <module>
    from distutils.spawn import find_executable
ModuleNotFoundError: No module named 'distutils'

It seems like the issue could be its dependence on Python 3.12, which no longer includes distutils in the standard library according to the Python 3.12 release notes.

I was able to get around this by dropping back to Python 3.11 as my default Python version, making sure the awsume module was installed with pip, and running the awsume-configure script directly instead of using the awsume-configure command.

I was then able to run awsume command with the alias in my .zshrc file

alias awsume=". awsume"
mtskillman commented 7 months ago

this will/was resolved by https://github.com/trek10inc/awsume/pull/239

we need to release new version of awsume soon to address this

lhendrick-t10 commented 7 months ago

Released 4.5.4.rc0 for testing - will publish full version bump today

lhendrick-t10 commented 5 months ago

Hey @matale - we have officially published 4.5.4 - can you confirm that this issue has been resolved?

metametadata commented 2 months ago

Reproducible in macOS Sonoma 14.4.1 for version 4.5.3:

~ ᐅ awsume-configure 
Traceback (most recent call last):
  File "/Users/yuri/.local/bin/awsume-configure", line 5, in <module>
    from awsume.configure.main import main
  File "/Users/yuri/.local/pipx/venvs/awsume/lib/python3.12/site-packages/awsume/configure/__init__.py", line 1, in <module>
    from awsume.configure import alias
  File "/Users/yuri/.local/pipx/venvs/awsume/lib/python3.12/site-packages/awsume/configure/alias.py", line 2, in <module>
    from distutils.spawn import find_executable
ModuleNotFoundError: No module named 'distutils'

we have officially published 4.5.4 - can you confirm that this issue has been resolved?

awsume-configure still fails, but now it's about setuptools:

~ ᐅ awsume-configure
Traceback (most recent call last):
  File "/Users/yuri/.local/bin/awsume-configure", line 5, in <module>
    from awsume.configure.main import main
  File "/Users/yuri/.local/pipx/venvs/awsume/lib/python3.12/site-packages/awsume/configure/__init__.py", line 4, in <module>
    from awsume.configure import post_install
  File "/Users/yuri/.local/pipx/venvs/awsume/lib/python3.12/site-packages/awsume/configure/post_install.py", line 1, in <module>
    from setuptools.command.install import install
ModuleNotFoundError: No module named 'setuptools'

In both cases I've installed awsume via pipx.

znd4 commented 2 weeks ago
pipx inject awsume setuptools

Is a workaround (at least for me)

cspotcode commented 4 days ago

I still see the distutils error on python 3.12, awsume 4.5.4.

❯ awsume --version
Warning: the awsume shell script is not being sourced, please use awsume-configure to install the alias
4.5.4
/home/ubuntu/.local/bin/awsume: line 183: return: can only `return' from a function or sourced script

❯ python --version
Python 3.12.3

❯ awsume-configure --version   
Traceback (most recent call last):
  File "/home/ubuntu/.local/bin/awsume-configure", line 5, in <module>
    from awsume.configure.main import main
  File "/home/ubuntu/.local/pipx/venvs/awsume/lib/python3.12/site-packages/awsume/configure/__init__.py", line 4, in <module>
    from awsume.configure import post_install
  File "/home/ubuntu/.local/pipx/venvs/awsume/lib/python3.12/site-packages/awsume/configure/post_install.py", line 1, in <module>
    from setuptools.command.install import install
  File "/home/ubuntu/.local/pipx/shared/lib/python3.10/site-packages/setuptools/__init__.py", line 10, in <module>
    import distutils.core
ModuleNotFoundError: No module named 'distutils'

Is python broken and trying pull python 3.10 packages into 3.12? Python's package handling always feels like such a mess, I don't know if I'm supposed to be seeing 3.10 in those traceback paths or not.

lhendrick-t10 commented 4 days ago

@cspotcode - digging back into this again. distutils was removed from Python 3.12 (deprecated in 3.10)

Looking into options to fix this in the distribution but for now separately injecting setuptools with pipx should shim until that fix can be implemented

cspotcode commented 4 days ago

@lhendrick-t10 unfortunately I already did pipx inject awsume setuptools, I still get the distutils error. I think the missing distutils is distinct from missing setuputils error.