Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"No module named 'msvcrt'" on Ubuntu 20.04 self-hosted runner #289

Closed
2 of 5 tasks
mikedalton opened this issue Dec 3, 2021 · 6 comments
Closed
2 of 5 tasks

"No module named 'msvcrt'" on Ubuntu 20.04 self-hosted runner #289

mikedalton opened this issue Dec 3, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@mikedalton
Copy link

Description:

When following instructions to set up an Ubuntu 20.04 self-hosted runner's tool cache with Python 3.10, subsequently running a workflow that checks out the repo, sets up python, sets up the scottbrenner/cfn-lint-action@v2 action, and then runs cfn-lint --version results in the following error:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/subprocess.py", line 69, in <module>
    import msvcrt
ModuleNotFoundError: No module named 'msvcrt'

Deploying the Python tool cache into the Actions runner client's _work/_tool directory results in a successful run of cfn-lint --version, but then with other workflows encounters errors building Docker containers.

Action version:

actions/setup-python@v2

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:

3.10 (others untested)

Repro steps:

  1. Build tool cache with following workflow step:
      - name: Setup Python 3.10
        uses: actions/setup-python@v2
        with:
          python-version: '3.10'
  1. As per setup-python instructions for deploying to hosted tool cache on Linux, copy and extract artifact to /opt/hostedtoolcache/

  2. Attempt to run the following workflow:

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Install Python
        uses: actions/setup-python@v2
        with:
          python-version: '3.x'

      - name: Setup Cloud Formation Linter with Latest Version
        uses: scottbrenner/cfn-lint-action@v2

      - name: Print the Cloud Formation Linter Version & run Linter.
        run: |
          cfn-lint --version
          cfn-lint

Expected behavior:

Successful run of second workflow, with an output similar to the following:

cfn-lint 0.55.0

Actual behavior:

Receive output similar to the following:

/opt/hostedtoolcache/Python/3.10.0/x64/bin/python3 --version
Python 3.10.0
/opt/hostedtoolcache/Python/3.10.0/x64/bin/python3 -m venv /tmp/setup-cfn-lint-3DRQLm/.venv
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/subprocess.py", line 69, in <module>
    import msvcrt
ModuleNotFoundError: No module named 'msvcrt'
....
  File "/opt/hostedtoolcache/Python/3.10.0/x64/lib/python3.10/subprocess.py", line 74, in <module>
    import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'

The output is very unusual, as it references module msvcrt (Microsoft VC++ runtime), despite nothing in the workflow, Python build, or Actions runner involving Windows or the VC++ runtime.

@mikedalton mikedalton added bug Something isn't working needs triage labels Dec 3, 2021
@misbahfhm
Copy link

how was it?
Was it solved?

I have a same problem there

@vineet-codes256
Copy link

I am also facing the same issue…

@sanxchep
Copy link

same and im using on Ubuntu 20.04

@dsame
Copy link
Contributor

dsame commented Apr 8, 2022

Hello @mikedalton,
I do not clearly understand your self-hosted agent setup. The README mentions AGENT_TOOLSDIRECTORY variable and i see no use of it in your steps.

As a quick workaround, please try your workflow avoiding AGENT_TOOLSDIRECTORY at all. See the sample build to understand what i mean:

https://github.com/akv-platform/python-msvcrt/runs/5880925955?check_suite_focus=true
and the corresponding workflow
https://github.com/akv-platform/python-msvcrt/actions/runs/2113585786/workflow

Despite it works or does not, please describe your current setup in order we could improve the documentation

  1. You've created /opt/hostedtoolcache and gran write permission on it to runner user - yes/no?
  2. You've run actions/setup-python@v2 with
      - name: Setup python
        uses: actions/setup-python@v2
        with:
          python-version: '3.x'
        env:
          AGENT_TOOLSDIRECTORY: /opt/hostedtoolcache

yes/no?

WARN: you may face Error: Version 3.10.4 with arch x64 not found message on the 2nd step. In the case please wait for #338 to be merged

@dsame
Copy link
Contributor

dsame commented Apr 20, 2022

Hello @mikedalton,
Just a gentle ping, we could use an update on this issue :)

@marko-zivic-93
Copy link
Contributor

Hello @mikedalton
Due to the lack of response, I am going to close this issue :)
If you have any additional problems or concerns, please feel free to reopen it or to create a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants