Couldn't build C module 'SwiftShims'

:0: error: could not build C module 'SwiftShims'


I have already followed the instructions and completely restarted 5 times. What is going on!

My guess is that the instructions were not followed precisely. This indicates that the (correct) Visual Studio Build Tools were not installed prior to the Swift installation. As a result the module map is either not installed or the wrong version of the tools are being selected.

I would uninstall swift, and then reinstall from the command line using .\installer.exe /lv*x and look through the logs to determine wat is happening during the deployment phase.

Alternatively follow the instructions to manually deploy the module map files.

Can you please explain the steps I would need to do to complete this?

The manual approach is documented in the getting started/installation instructions on swift.org

For further investigating the installation issue, .\installer.exe /lv*x should be sufficient for producing the necessary logs for determining what happened during the deployment process.

I am sorry but that is the issue, I have done every guide for windows that is listed. I am not sure how to do what the .\installer.exe thing is.

Could you please explain why the VS has to be 2019?

I am having VS 2022 installed on my machine for latest dotnet development. I wonder whether installing multiple Visual Studio versions could cause troubles.

VS 2022 is fine :slightly_smiling_face:

1 Like

According to your instruction:

I tried installing Python 3.9 on a fresh-installed windows 10 (21H2) in this way, but the new cmdline shells (CMD, PWSH, Nu Shell, etc.) have no one responds to the pip command.

P.S.: I thought that this must happen. Python is the most irritating thing to deploy on macOS, and now Windows.

Here's the path:
截圖 2023-10-08 16.36.34

Are you sure that you opened a new command line window after installing Python?

Can you find the “pip” command following the paths (notice that you typed “pip3”, is this available)? Or is pip missing in your Python installation?

  1. The right-side PowerShell window is the new window I opened after installing Python 3.
  2. On macOS and linux I somehow have to use pip3 in order not to trigger the pip2. I thought that on Windows it also has the pip3 alternative. As you see, both pip and pip3 fail from working.

Update: I manually downloaded the installer from Python official website, and I confirmed that my remove-and-reinstall process includes adding-to-PATH. It still doesn't work. Sigh.

This is Python. I hate its hassles deploying on macOS, and I learnt Swift to write lots of Swift scripts instead. Now, on Windows, I have to use Python to get Swift works? .......

You first might have a look what the exact problem is. You have a new Python installation, so:

  • Are the entries in the PATH environment variable pointing to that installation?
  • The pip command should be in the “Scripts” subfolder of the Python installation, can you find it there?
  • If it is there, is the according folder listet in the PATH environment variable?
  • If all is OK so far, can you execute “pip” in a new command line window (I woul€ start trying a cmd window)?
  • What if you uninstall Python and install it again?

There is obviously some problem, but without some further investigation on your part it is difficult for other people to see what the problem might be.

I tried uninstall-and-install. This is the PATH now:

It still does not work in a new terminal window for PWSH and NuShell.

However, the Visual Studio CMD prompt works for Python now. I just have to use those DOS commands.

Python is only needed for the REPL or debugging (I think for debugging this stems from the LLVM debugger which uses Python for configuration), not for compiling or running. Note that you need the exact minor version of Python as documented for the Swift version.

1 Like

Now I can prove that the terminal emulator matters. Maybe Fluent Terminal needs extra configuration to work with PATHs. Microsoft Windows Terminal has no problem using pip with NuShell.

Well, it should work in a pure (and new) PowerShell window, too.

1 Like

Thanks. It's assumable. I just prefer NuShell: It offers a more bash-like experience comparing to PWSH. It does have a lot of differences comparing to bash, still.

Then NuShell should maybe be restartet?

So all is solved. :slightly_smiling_face: Have fun with Swift!

1 Like

Thanks. The PIP problem is solved.

However, the SwiftShim issue still exists. I am manually installing 2019 VC Tools components through VS 2022 installer to see whether it can fix this.