Posted in Computer Science, Programming

.py to .exe in Python 3.6.1

The thing is, I suffered a lot to do this. Spent many days working on it. Finally, I got the answer. I realized that I got not only the answer but also an ImportError.  Then, I found a solution for that too and I made my python script to an application. Wanna know how? Follow the following steps and so you make people to follow you. Have a nice day 🙂

Steps to convert .py to .exe in Python 3.6

  1. You must be installed Python 3.6 and cx_Freeze.
  2. To install cx_Freeze, open your command prompt and type ‘pip install cx_Freeze
  3. make a .py program of yourself say ‘my first’ .
  4. Create a new python file named ‘’ on the current directory of your script.
  5. On the, code this and save it.
  6. With shift pressed right click on the same directory, so you are able to open a command prompt window.
  7. Type in the prompt as >> python build
  8. If your script is error free, then there is no problem on creating application. Check the newly created folder ‘build‘. It has another folder in it. Within that folder you can able to find your application. Run it. Make yourself happy.

Wanna know your try and your success. Don’t forget to share your comments.

Also take a look How to send notifications to your phone using python script. Code Sheet of Python is also available.


Maria Irudaya Regilan J



I am J Maria Irudaya Regilan from Chennai. A programmer who urges to develop new things and think on revolutionary ideas that could change the world. I am not enough good in internet but I am on my effort to stand alone. I am inspired by some great men like Sundar Pichai (a local guy from my hometown), Bill Gates, Mark Zuckerberg, Steve Jobs, Elon Musk and sorry, I can't tell everyone since the list goes more than I thought. I like to get beaten up by my own projects, because they test my confidence and ability to get up. Follow my blog and stay connected for receiving ideas on programming languages. Have a cup of coffee!!

55 thoughts on “.py to .exe in Python 3.6.1

  1. Hey, thanks for the tutorial, when i run python build i get the error “ImportError: No module named ‘inda’”. Any idea on a fix?


  2. Hi, Maria,
    it’s good to see your blog. It’s very helpful.
    I got the built file under build>>main.exe, and python36.dll. But i can’t run it.
    This is the error infomation.
    PS D:\Python\SnakeGame> python build
    running build
    running build_exe
    creating directory build\
    copying C:\Users\Zhitao\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\bases\Console.exe -> build\\main.exe
    copying C:\Users\Zhitao\AppData\Local\Programs\Python\Python36\python36.dll -> build\\python36.dll
    Traceback (most recent call last):
    File “C:\Users\Zhitao\AppData\Local\Programs\Python\Python36\lib\site-packages\win32\lib\”, line 120, in stamp
    bits = [int(i) for i in ver.split(“.”)]
    File “C:\Users\Zhitao\AppData\Local\Programs\Python\Python36\lib\site-packages\win32\lib\”, line 120, in
    bits = [int(i) for i in ver.split(“.”)]
    ValueError: invalid literal for int() with base 10: ”
    During handling of the above exception, another exception occurred:
    Traceback (most recent call last):
    File “”, line 26, in
    executables = executables
    File “C:\Users\Zhitao\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\”, line 349, in setup
    File “C:\Users\Zhitao\AppData\Local\Programs\Python\Python36\lib\distutils\”, line 148, in setup
    File “C:\Users\Zhitao\AppData\Local\Programs\Python\Python36\lib\distutils\”, line 955, in run_commands
    File “C:\Users\Zhitao\AppData\Local\Programs\Python\Python36\lib\distutils\”, line 974, in run_command
    File “C:\Users\Zhitao\AppData\Local\Programs\Python\Python36\lib\distutils\command\”, line 135, in run
    File “C:\Users\Zhitao\AppData\Local\Programs\Python\Python36\lib\distutils\”, line 313, in run_command
    File “C:\Users\Zhitao\AppData\Local\Programs\Python\Python36\lib\distutils\”, line 974, in run_command
    File “C:\Users\Zhitao\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\”, line 219, in run
    File “C:\Users\Zhitao\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\”, line 623, in Freeze
    File “C:\Users\Zhitao\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\”, line 225, in _FreezeExecutable
    File “C:\Users\Zhitao\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\”, line 166, in _AddVersionResource
    stamp(fileName, versionInfo)
    File “C:\Users\Zhitao\AppData\Local\Programs\Python\Python36\lib\site-packages\win32\lib\”, line 123, in stamp
    raise ValueError(“–version must be a.b.c.d (all integers) – got %r” % ver)
    ValueError: –version must be a.b.c.d (all integers) – got ‘.0.0.0’
    PS D:\Python\SnakeGame> python build
    running build
    running build_exe
    thank you.


    1. Thanks for your support… We are working to post some best posts that will be useful for you. On dealing with errors we could see a ValueError. If your have both the int() error and ValueError then change your script by using some more exception handling blocks. This will sure helps you. I trust you have a snake game application soon.


      1. hi, I got the same problem as Zhitao, please help, I also tried using pyinstaller and py2exe but none of them worked.


  3. I too got a similar error to Zhitao. Not sure this solution works as it appears to be same issue as py2exe and python 3.6


  4. Hey…many thanks for this useful tutorial… just 2 quick questions: Any suggestion on how to convert it to a single exe file? also, how to reduce the file size? thanks.


  5. Hi Maria,
    very good tool!!! All others I tried are not working, so yours is the best! 🙂
    One comment:
    In addition to install “cx_Freeze” I have to install “inda” too. This is not mentioned
    One question:
    Some tools give an option to use key for encryption of source codes. I expect in executable file we have interpreter and sources, right? So, is it possible to have this option?
    Best regards


  6. Hi, I followed everything through and managed to make the .exe file of the Python program I had. In my original Python script I had imported the tweepy module which I had installed using pip. Now when I try to run the .exe file I get an error telling me that the tweepy module can’t be found. I reinstalled tweepy from command line using pip and I tried running the .exe file again and it still doesn’t work. It’s strange because when I run the Python file it works. Do you know how I can get it to run as the .exe file?


  7. Very good described steps from Maria.

    To the issue of “ImportError: No module named ‘inda’”:
    2. To install cx_Freeze, open your command prompt and type ‘pip install cx_Freeze‘
    To install idna, in command prompt type “pip install -I –user pyopenssl”


  8. Maybe a silly question, but how to make “pip install cx_Freeze” work on Windows console command? Let me just add that I’ve tried adding path to python script to system variables just to get info that ‘pip’ is not recognized as an internal or external command… And does so basic feature must be really so hard to turn on. What do you all guys do with python applications? Run in compilers only???


  9. hi, Maria,thanks for your tutorial. I followed your steps, I got the similar error to Zhitao, and I changed version value”” to “”, so it is error free. But when I double clicked the exe, it flashed back. Do you know why?


  10. Thanks for the post. I was able to build an exe. When I run the exe, I get an error message
    “Import Error : cannot import name ‘_methods’”
    Please advise whats missing. Thanks


    1. Add these things in your

      addtional_mods = [‘numpy.core._methods’, ‘numpy.lib.format’]
      setup(name=…, version=…, description=…, options = {‘build_exe’: {‘includes’: addtional_mods}}, executables = … )

      Convert it again and I hope this will help you. Thanks for your comment and don’t forget to follow the blog to get our new posts.


  11. O que fazer?
    Ao tentar:
    “python build” ===> “No module named ‘idna’

    Segui sua recomendação:

    “pip install -I -user pyopenssl” ===> “no such option: -u”

    E agora?


  12. when i tried to run the exe file it displays following error. what should i do?
    Fatal Python error: Py_Initialize: unable to load the file system codec
    Traceback (most recent call last):
    File “C:\Users\SHEKAR\AppData\Local\Programs\Python\Python36-32\lib\encodings\”, line 31, in
    ModuleNotFoundError: No module named ‘codecs’


  13. Hey, thanks for the tutorial, when I run python build I encounter this error :
    raise ValueError(“–version must be a.b.c.d (all integers) – got %r” % ver)
    ValueError: –version must be a.b.c.d (all integers) – got ‘.0.0.0’
    how can I fix it ?
    thank you ,,


  14. I ran the codes and this error appears: “SyntaxError: unexpected EOF while parsing” with an arrow point right below the “.” in File “C:\Data Discrepency\”, line 27

    Any idea on how to fix. Thank you very much for helping out!


  15. The build worked fine, however for some reason I have an issue where the application will not open. It quickly opens up a command prompt, however that closes almost immediately after. Is there something I am missing?


    1. thanks for reaching us! Actually it is the console window that runs the program you have coded. If you don’t want the console window, make your own graphics on the program using some of our pythonic libraries like Turtle. Follow us for more news!


      1. Hi, thanks for your answer. The console window does not bother me when the program starts. The problem is when there are two windows in the start bar. One is my program and the other is the console window.


  16. I followed you directions and got this error when I run the file. I use pandas, but not specifically numpy. Any ideas? I imported numpy in my code, and it still happens (even though I don’t need to import numpy in my code for it to run)

    (bandwidth36) C:\GitHub\bandwidth\build\>find_numbers.exe
    Traceback (most recent call last):
    File “C:\Python\Anaconda3\envs\bandwidth36\lib\site-packages\cx_Freeze\initscripts\”, line 14, in run
    File “C:\Python\Anaconda3\envs\bandwidth36\lib\site-packages\cx_Freeze\initscripts\”, line 26, in run
    exec(code, m.__dict__)
    File “”, line 4, in
    File “C:\Python\Anaconda3\envs\bandwidth36\lib\site-packages\pandas\”, line 19, in
    “Missing required dependencies {0}”.format(missing_dependencies))
    ImportError: Missing required dependencies [‘numpy’]


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s