# How to build MSI installer for Python 3.9.5 on Windows 10?

**URL:** <https://discuss.python.org/t/how-to-build-msi-installer-for-python-3-9-5-on-windows-10/43737>\
**Category:** Python Help\
**Created:** [January 21, 2024, 6:02am UTC](https://discuss.python.org/t/how-to-build-msi-installer-for-python-3-9-5-on-windows-10/43737 "2024-01-21T06:02:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![T990820](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/t990820/32/17328_2.png) [@T990820](https://discuss.python.org/u/T990820)\
**Post date:** [January 21, 2024, 6:02am UTC](https://discuss.python.org/t/how-to-build-msi-installer-for-python-3-9-5-on-windows-10/43737/1 "2024-01-21T06:02:16Z")

</div>

I am building the MSI installer for python 3.9.5 using  
`Tools\msi\build.bat -x64`  
But it says

> LNK1104: cannot open file “libffi-7.lib”

I am using the following software versions:

- git version 2.43.0.windows.1
- Microsoft Visual Studio Enterprise 2019 version 16.11.33

The source code is downloaded from [https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tgz](https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tgz). Does anyone have any ideas as to what might be going wrong and/or how to fix it?

---

<div class="post-metadata">

**Author:** ![barry-scott](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@barry-scott](https://discuss.python.org/u/barry-scott)\
**Post date:** [January 21, 2024, 9:12am UTC](https://discuss.python.org/t/how-to-build-msi-installer-for-python-3-9-5-on-windows-10/43737/2 "2024-01-21T09:12:37Z")

</div>

Did you build libffi as part of providing the dependencies for python?

---

<div class="post-metadata">

**Author:** ![T990820](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/t990820/32/17328_2.png) [@T990820](https://discuss.python.org/u/T990820)\
**Post date:** [January 21, 2024, 5:05am UTC](https://discuss.python.org/t/how-to-build-msi-installer-for-python-3-9-5-on-windows-10/43737/3 "2024-01-21T05:05:01Z")

</div>

> [@Where to download Python 3.11 alpha 1](https://discuss.python.org/t/where-to-download-python-3-11-alpha-1/43710/2):
>
> idiosyncratic

Thank you for your reply. I am compiling the source code for python 3.9.5 using Tools\msi\build.bat. But it said

> Blockquote fatal error LNK1104: cannot open file “libffi-7.lib”

According to the original topic, I think there is something wrong with the code downloaded from [https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tgz](https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tgz). And there is no python 3.9.5 source code in [GitHub - python/cpython: The Python programming language](https://github.com/python/cpython), so I put forward this problem.

---

<div class="post-metadata">

**Author:** ![kknechtel](https://avatars.discourse-cdn.com/v4/letter/k/e47c2d/32.png) [@kknechtel](https://discuss.python.org/u/kknechtel)\
**Post date:** [January 21, 2024, 5:16am UTC](https://discuss.python.org/t/how-to-build-msi-installer-for-python-3-9-5-on-windows-10/43737/4 "2024-01-21T05:16:38Z")

</div>

This doesn’t look related to the original question at all, and downloading that release of 3.11 would definitely not solve the problem. It looks like you simply don’t have a required dependency set up for compiling Python. Please start by reading [about building Python in the main documentation](https://docs.python.org/3/using/unix.html#building-python), and/or check out the [setup and building](https://devguide.python.org/getting-started/setup-building/index.html) chapter in the development guide.

---

<div class="post-metadata">

**Author:** ![Jelle](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jelle/32/1049_2.png) [@Jelle](https://discuss.python.org/u/Jelle)\
**Post date:** [January 21, 2024, 5:18am UTC](https://discuss.python.org/t/how-to-build-msi-installer-for-python-3-9-5-on-windows-10/43737/5 "2024-01-21T05:18:48Z")

</div>

> [@T990820](#):
>
> And there is no python 3.9.5 source code in [GitHub - python/cpython: The Python programming language](https://github.com/python/cpython), so I put forward this problem.

It’s there: [Release v3.9.5 · python/cpython · GitHub](https://github.com/python/cpython/releases/tag/v3.9.5)

---

<div class="post-metadata">

**Author:** ![CAM-Gerlach](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cam-gerlach/32/3688_2.png) [@CAM-Gerlach](https://discuss.python.org/u/CAM-Gerlach)\
**Post date:** [January 21, 2024, 5:19am UTC](https://discuss.python.org/t/how-to-build-msi-installer-for-python-3-9-5-on-windows-10/43737/6 "2024-01-21T05:19:37Z")

</div>

FYI, there’s no need to keep editing your post over and over to try to get the formatting right. Instead, simply use the live preview pane right next to text box, which is exactly why it is there.

> [@T990820](#):
>
> I am compiling the source code for python 3.9.5

I’m curious as to the reason you’re compiling such an old feature version, and a particularly old patch version thereof (3.9.18 is the latest). Why not simply use the binary installers for that version (or compile a more recent one)?

> [@T990820](#):
>
> Tools\msi\build.bat.

That builds the MSI installer, not Python itself, which is normally something that only the release managers need to do, and you can get said installer already built for you on the [Python.org](http://Python.org) download page.

> [@T990820](#):
>
> According to the original topic, I think there is something wrong with the code downloaded from [https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tgz](https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tgz).

According to the original topic, the error occurred on Python 3.11.0a1, and ended up being apparently user error. Furthermore, the title of this topic requested how to download that aforementioned version. Therefore, I don’t really understand why you’re asking this, sorry.

> [@T990820](#):
>
> And there is no python 3.9.5 source code in [GitHub - python/cpython: The Python programming language](https://github.com/python/cpython),

Sure there is; you just have to check out the corresponding tag after you’ve cloned the repo (`git checkout v3.9.5`) as I’ve previously stated, or you can [view it online](https://github.com/python/cpython/tree/v3.9.5).

---

<div class="post-metadata">

**Author:** ![T990820](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/t990820/32/17328_2.png) [@T990820](https://discuss.python.org/u/T990820)\
**Post date:** [January 21, 2024, 7:42am UTC](https://discuss.python.org/t/how-to-build-msi-installer-for-python-3-9-5-on-windows-10/43737/8 "2024-01-21T07:42:47Z")

</div>

Thank you for your reply. I got solution from [Problems with building CPython - #4 by Thoufak](https://discuss.python.org/t/problems-with-building-cpython/19310/4). Actually, there is really something wrong with the downloaded source code of Python 3.9.5. I modified the following files according to [bpo-45022: Pin current libffi build to fixed version in preparation f… · python/cpython@399cd46 · GitHub](https://github.com/python/cpython/commit/399cd466d0379d12e4af343a49ca7e8ec84997fa), and it works.

- PCbuild/get\_externals.bat
- PCbuild/prepare\_libffi.bat
- PCbuild/python.props

---

<div class="post-metadata">

**Author:** ![CAM-Gerlach](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cam-gerlach/32/3688_2.png) [@CAM-Gerlach](https://discuss.python.org/u/CAM-Gerlach)\
**Post date:** [January 21, 2024, 4:43pm UTC](https://discuss.python.org/t/how-to-build-msi-installer-for-python-3-9-5-on-windows-10/43737/9 "2024-01-21T16:43:04Z")

</div>

As mentioned previously, is there a reason you can’t simply use the latest patch 3.9 version, 3.9.18, as opposed the long-outdated 3.9.5? It fixes hundreds of bugs and security issues, including the build problem you encountered, while being a drop-in, backward-compatible replacement for 3.9.5.

(N.B., since you created another thread on this actual topic, and others were already trying to help you here when it was apparently solved already, I moved the relevant posts over here)

---

<div class="post-metadata">

**Author:** ![Jn1014](https://avatars.discourse-cdn.com/v4/letter/j/e480ec/32.png) [@Jn1014](https://discuss.python.org/u/Jn1014)\
**Post date:** [September 18, 2024, 4:51am UTC](https://discuss.python.org/t/how-to-build-msi-installer-for-python-3-9-5-on-windows-10/43737/10 "2024-09-18T04:51:27Z")

</div>

Hello, do you mind sharing how did you manage to build the Python MSI installer? Thank you in advance!
