Python Forum

Full Version: Python 3.6 to executable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I now do:
C:\Users\Adriaan>cd C:\
C:\>python -m venv qustion_env
#
#At this point it opens a window that says: python doesn't work properly anymore, it's #shutting down, after wich te following comes up on my cmd:
#
Error: Comman '[\\qustion_env\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 3221226505

What did I do wrong??
(Jan-15-2018, 10:10 PM)DeGerlash Wrote: [ -> ]What did I do wrong??
Python and pip command most work from cmd.
C:\>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

C:\>pip -V
pip 9.0.1 from c:\python36\lib\site-packages (python 3.6)

C:\>
I gave you this link in post #8
Python 3.6 and pip installation under Windows
It gives me this:
C:\>python
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

C:\>pip -V
pip 9.0.1 from c:\users\adriaan\.thonny\bundledpython36\lib\site-packages (python 3.6)

C:\>
Thonny have installed pip into Windows PATH Environment.
I would remove that so that pip point to the OS installation of Python 3.6.
Look at this post of how to remove and add to Windows PATH Environment.
Remember restart PC and test pip again from cmd.
Thanks, so I did the PATH thing, but now it goes (in cmd):
C:\Users\Adriaan>cd C:\Users\Adriaan\AppData\Local\Programs\Thonny

C:\Users\Adriaan\AppData\Local\Programs\Thonny>pip

Usage:
  pip <command> [options]

Commands:
  install                     Install packages.
  download                    Download packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  check                       Verify installed packages have compatible dependencies.
  search                      Search PyPI for packages.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  --isolated                  Run pip in an isolated mode, ignoring
                              environment variables and user configuration.
  -v, --verbose               Give more output. Option is additive, and can be
                              used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output. Option is additive, and can be
                              used up to 3 times (corresponding to WARNING,
                              ERROR, and CRITICAL logging levels).
  --log <path>                Path to a verbose appending log.
  --proxy <proxy>             Specify a proxy in the form
                              [user:passwd@]proxy.server:port.
  --retries <retries>         Maximum number of retries each connection should
                              attempt (default 5 times).
  --timeout <sec>             Set the socket timeout (default 15 seconds).
  --exists-action <action>    Default action when a path already exists:
                              (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.
  --trusted-host <hostname>   Mark this host as trusted, even though it does
                              not have valid or any HTTPS.
  --cert <path>               Path to alternate CA bundle.
  --client-cert <path>        Path to SSL client certificate, a single file
                              containing the private key and the certificate
                              in PEM format.
  --cache-dir <dir>           Store the cache data in <dir>.
  --no-cache-dir              Disable the cache.
  --disable-pip-version-check
                              Don't periodically check PyPI to determine
                              whether a new version of pip is available for
                              download. Implied with --no-index.

C:\Users\Adriaan\AppData\Local\Programs\Thonny>pip install pyinstaller
Requirement already satisfied: pyinstaller in c:\users\adriaan\.thonny\bundledpython36\lib\site-packages
Requirement already satisfied: setuptools in c:\users\adriaan\.thonny\bundledpython36\lib\site-packages (from pyinstaller)
Requirement already satisfied: pefile>=2017.8.1 in c:\users\adriaan\.thonny\bundledpython36\lib\site-packages (from pyinstaller)
Requirement already satisfied: macholib>=1.8 in c:\users\adriaan\.thonny\bundledpython36\lib\site-packages (from pyinstaller)
Requirement already satisfied: future in c:\users\adriaan\.thonny\bundledpython36\lib\site-packages (from pyinstaller)
Requirement already satisfied: altgraph>=0.15 in c:\users\adriaan\.thonny\bundledpython36\lib\site-packages (from macholib>=1.8->pyinstaller)

C:\Users\Adriaan\AppData\Local\Programs\Thonny>pyinstaller EnglishWordGenerator2.py
175 INFO: PyInstaller: 3.3.1
175 INFO: Python: 3.6.1
178 INFO: Platform: Windows-10-10.0.16299-SP0
179 INFO: wrote C:\Users\Adriaan\AppData\Local\Programs\Thonny\EnglishWordGenerator2.spec
181 INFO: UPX is not available.
183 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Adriaan\\AppData\\Local\\Programs\\Thonny',
 'C:\\Users\\Adriaan\\AppData\\Local\\Programs\\Thonny']
184 INFO: checking Analysis
214 INFO: checking PYZ
227 INFO: checking PKG
228 INFO: Bootloader c:\users\adriaan\.thonny\bundledpython36\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe
228 INFO: checking EXE
232 INFO: checking COLLECT
234 INFO: Building COLLECT out00-COLLECT.toc
462 INFO: Building COLLECT out00-COLLECT.toc completed successfully.

C:\Users\Adriaan\AppData\Local\Programs\Thonny>
Then I go to the 'dist' folder and I run the .exe, but now it doesn't flash the error, it only stops immediately after I give the last command. This can't be because the program is 'finished'!

This is the program:
from time import time
import random
key=input("Press any key and then enter to start ... ")
while key!="":
    alphabet=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
    distribution=[0,0,1,6,26,52,85,122,140,140,126,101,75,52,32,20,10,6,3,2,1,1,0,0,0,0]
    word=""
    counter=0
    wordtype=""
    chance=0
    timeonbatteryseconds=0
    timeonACseconds=0
    runlengthcalculator=0
    x=0
    y=0
    timescounter=0
    howmanywords=0

    def howmany(wordlength):
        howmanywords=0
        if language=="dutch" or language=="Dutch" or language=="nl" or language=="NL" or language=="nederlands" or language=="Nederlands" or language=="Nl":
            file = open("DutchWords.txt", "r")
            for element in file.readlines():
                if len(str(element))==int(wordlength)+1:
                    howmanywords+=1
            return howmanywords
        if wordtype=="common":
            file = open("CommonEnglishWords.txt", "r")
            for element in file.readlines():
                if len(str(element))==int(wordlength)+1:
                    howmanywords+=1
            return howmanywords
        if wordtype=="all":
            file = open("AllEnglishWords.txt", "r")
            for element in file.readlines():
                if len(str(element))==int(wordlength)+1:
                    howmanywords+=1
            return howmanywords

    def isValid(word):
        if language=="dutch" or language=="Dutch" or language=="nl" or language=="NL" or language=="nederlands" or language=="Nederlands" or language=="Nl":
            file = open("DutchWords.txt", "r")
            if word in file.read():
                return True
            else:
                return False
        if wordtype=="common":
            file = open("CommonEnglishWords.txt", "r")
            if word in file.read():
                return True
            else:
                return False
        if wordtype=="all":
            file = open("AllEnglishWords.txt", "r")
            if word in file.read():
                return True
            else:
                return False


    language=input("What language do you wish to proceed in? (dutch/english) ")

    if language=="" or language=="choose" and language!="dutch" and language!="Dutch" and language!="nl" and language!="NL" and language!="nederlands" and language!="Nederlands" and language!="Nl" and language!="english" and language!="English" and language!="Eng" and language!="eng":
        decider=random.randint(0,1)
        if decider==0:
            language="English"
            print("I'm gonna go with English.")
        if decider==1:
            language="Dutch"
            print("Laten we nederlands nemen.")
        
    if language=="english" or language=="English" or language=="Eng" or language=="eng":
        wordtype=input("What words do you want to generate? (common/all) ")
        if wordtype=="choose" or wordtype=="":
            decider=random.randint(0,1)
            if decider==0:
                wordtype="common"
                print("Let's only generate common words.")
            if decider==1:
                wordtype="all"
                print("Let's generate all words!")
        wordlength=input("How many characters do you want the word to have? ")
    if language=="dutch" or language=="Dutch" or language=="nl" or language=="NL" or language=="nederlands" or language=="Nederlands" or language=="Nl":
        wordlength=input("Hoelang moet het woord zijn? ")
                
    if wordlength=="choose" or wordlength=="kies" or wordlength=="kies maar" or wordlength=="kies zelf" or wordlength=="goh kies maar zelf" or wordlength=="goh kies maar" or wordlength=="aan u de keuze" or wordlength=="":
        x=random.randint(0,999)
        wordlength=7
        if x==0:
            wordlength=1
        for element in distribution:
            if x in range(y+1,y+element):
                wordlength=timescounter
                break
            timescounter+=1
            y+=element
            
        chance=float(((howmany(wordlength))/(26**wordlength))*100)
        timeonbatteryseconds=float(((26**int(wordlength))*1.5)*(10**(-9)))
        timeonACseconds=float(((26**int(wordlength))*3.6)*(10**(-9)))
            
        if language=="dutch" or language=="Dutch" or language=="nl" or language=="NL" or language=="nederlands" or language=="Nederlands" or language=="Nl":
            print("Laten we "+str(wordlength)+" letters nemen.")
            print("De kans dat dit me lukt is "+str(chance)+"%, want er zijn "+str(howmany(wordlength))+" nederlandse woorden met "+str(wordlength)+" letters.")
            #print("Aan netstroom zou dit ongeveer "+str(timeonACseconds)+" seconden duren.")
            #print("Op batterijstroom duurt dit waarschijnlijk echter "+str(timeonbatteryseconds)+" seconden. Maar ondertussen al weer minder natuurlijk!")
            print("Aan het genereren...")
        if language=="english" or language=="English" or language=="Eng" or language=="eng":
            if wordtype=="common":
                print("The chance of me pulling this off is "+str(chance)+"%, as there are "+str(howmany(wordlength))+" common English words with "+str(wordlength)+" characters.")
            if wordtype=="all":
                print("The chance of me pulling this off is "+str(chance)+"%, as there are "+str(howmany(wordlength))+" English words with "+str(wordlength)+" characters.")
            print("I'm gonna go for "+str(wordlength)+" characters.")
            #print("On AC power, this should take around "+str(timeonACseconds)+" seconds.")
            #print("On battery power, this'll probably take "+str(timeonbatteryseconds)+" seconds. But now already a lot less of course!")
            print("Generating...")
    else:
        wordlength=int(wordlength)
        
        chance=float(((howmany(wordlength))/(26**wordlength))*100)
        timeonbatteryseconds=float((26**int(wordlength))/(1.5*(10**9)))
        timeonACseconds=float((26**int(wordlength))/(3.6*(10**9)))
        
        if language=="dutch" or language=="Dutch" or language=="nl" or language=="NL" or language=="nederlands" or language=="Nederlands" or language=="Nl":
            print("De kans dat dit me lukt is "+str(chance)+"%, want er zijn "+str(howmany(wordlength))+" nederlandse woorden met "+str(wordlength)+" letters.")
            #print("Aan netstroom zou dit ongeveer "+str(timeonACseconds)+" seconden duren.")
            #print("Op batterijstroom duurt dit waarschijnlijk echter "+str(timeonbatteryseconds)+" seconden. Maar ondertussen al weer minder natuurlijk!")
            print("Aan het genereren...")
        if language=="english" or language=="English" or language=="Eng" or language=="eng":
            if wordtype=="common":
                print("The chance of me pulling this off is "+str(chance)+"%, as there are "+str(howmany(wordlength))+" common English words with "+str(wordlength)+" characters.")
            if wordtype=="all":
                print("The chance of me pulling this off is "+str(chance)+"%, as there are "+str(howmany(wordlength))+" English words with "+str(wordlength)+" characters.")
            #print("On AC power, this should take around "+str(timeonACseconds)+" seconds.")
            #print("On battery power, this'll probably take "+str(timeonbatteryseconds)+" seconds. But now already a lot less of course!")
            print("Generating...")
            
    starttime=time()

    while counter<=wordlength:
        word=word+alphabet[random.randint(0,25)]
        
        if len(word)==wordlength:
            if isValid("\n"+word+"\n")==True:
                if language=="english" or language=="English" or language=="Eng" or language=="eng":
                    print("The generated word is: "+word)
                if language=="dutch" or language=="Dutch" or language=="nl" or language=="NL" or language=="nederlands" or language=="Nederlands" or language=="Nl":
                    print("Het gecreƫerde woord is: "+word)
            else:
                word=""
                counter=0
        counter=counter+1
        runlengthcalculator=runlengthcalculator+1
        
    endtime=time()
    timetaken=endtime-starttime
    if language=="dutch" or language=="Dutch" or language=="nl" or language=="NL" or language=="nederlands" or language=="Nederlands" or language=="Nl":
        print("Dit heeft ongeveer "+str(round(timetaken,2))+" seconden geduurd.")
        key=input("Druk op eender welke toets en dan enter om een ander woord te creƫren, druk enter om af te sluiten ... ")
    if language=="english" or language=="English" or language=="Eng" or language=="eng":
        print("This took around "+str(round(timetaken,2))+" seconds.")
        key=input("Press any key and then enter to generate another word, press enter to close ... ")
    counter=0

Actually, now you have the code, could you maybe just compile it into a .exe file yourself and transfer it all to me? That way it could maybe work!
Pages: 1 2