Understanding Errors in pyinstaller myprogram.py --onefile -- debug all

Asked 2 years ago, Updated 2 years ago, 108 views

Environment:
Windows 10 Anaconda3

Python files were exeged in PyInstaller, but an error occurred.

 (practice) C:\Users\genki\Downloads> C:\Users\genki\Downloads\dist\test05.exe
Traceback (most recent call last):              
  File "test05.py", line 13, in <module>                
    get_ipython().system('pip3install webdriver_manager')              
NameError: name 'get_ipython' is not defined                
[14540] Failed to execute script test 05             

We looked at the following sites to find out.

How to investigate when the executable (.exe) created by PyInstaller does not work

 (practice) C:\Users\genki\Downloads>pyinstaller myprogram.py --onefile--debug all                      
109 INFO: PyInstaller: 3.6                      
109 INFO: Python: 3.9.7 (conda)                     
140 INFO: Platform: Windows-10-10.0.19043-SP0                       
140 INFO:wrotte C:\Users\genki\Downloads\myprogram.spec                     
140 INFO: UPX is not available.                     
Traceback (most recent call last):                      
  File "C:\Users\genki\anaconda3\envs\practice\Scripts\pyinstaller-script.py", line 10, in <module>                     
    sys.exit(run())                     
  File "C:\Users\genki\anaconda3\envs\practice\lib\site-packages\PyInstaller\__main__.py", line 114, in run                     
    run_build(pyi_config, spec_file, **vars(args))                      
  File "C:\Users\genki\anaconda3\envs\practice\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build                        
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)                       
  File "C:\Users\genki\anaconda3\envs\practice\lib\site-packages\PyInstaller\building\build_main.py", line 734, main                     
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build')))                      
  File "C:\Users\genki\anaconda3\envs\practice\lib\site-packages\PyInstaller\building\build_main.py", line 681, built                        
    exec(code,spec_namespace)                      
  File "C:\Users\genki\Downloads\myprogram.spec", line 6, in <module>                       
    a = Analysis (['myprogram.py'],                      
  File "C:\Users\genki\anaconda3\envs\practice\lib\site-packages\PyInstaller\building\build_main.py", line 191, in__init__                     
    raiseValueError("script'%s'not found"%script)                      
ValueError: script'C:\Users\genki\Downloads\myprogram.py'not found                        

I tried to find a clue to the solution by searching for the error statement below.

 raise ValueError("script'%s'not found"%script) ValueError: does not match script'C:\Users\genki\Downloads\myprogram.py'not found.

Professor, thank you for your cooperation.

.py file

#!/usr/bin/env python
# coding —utf-8

# In [1]:


#! pip3 install-U selenium


# In [1]:


get_ipython().system('pip3install webdriver_manager')


# In[2]:


from selenium import webdriver                  
from webdriver_manager.chrome import ChromeDriverManager


# In[3]:


driver = webdriver.Chrome (ChromeDriverManager().install())                      
driver.get('https://scraping-for-beginner.herokuapp.com/login_page')


# In[4]:


elem_username=driver.find_element_by_id('username')                   
elem_username.send_keys('imanishi')


# In [1]:





# In [ ]:

~Additional
▲ Below is my process.

1. Launch Anaconda Prompt.
2.(base) C:\Users\genki>conda activate practice
3, (practice) C:\Users\genki>conda install pyinstaller
4, (practice) C:\Users\genki>cd C:\Users\genki\Downloads
5, (practice) C:\Users\genki\Downloads>pyinstaller test05.py

The test05 person folder is created in the ...dist folder.
There is a test05.exe file in the test05 folder.
W-click on the ...test05.exe file and it disappears.
Run the ...test05.exe file at the "anaconda prompt" (below).

(practice) C:\Users\genki\Downloads> C:\Users\genki\Downloads\dist\test05\test05.exe
Traceback (most recent call last):
File "test05.py", line 19, in
from selenium import webdriver ModuleNotFoundError: No module named 'selenium'
[2252] Failed to execute script test05

…The above error is the same error as the two comment out

▲ "And by the way... Have you checked?"""My own process

""

...converted from Jupiter Lab to .py.
...w-click test05.py.
...Launching VsCode.
…terminal execution.
…I will write it down below. (Intermediate division due to long length)

PSC:\Users\genki>conda activate base
conda —The term 'conda' is not recognized as a cmdlet, function, script file, or name of an operational program.Make sure the name is written correctly, and if it contains a path, make sure it is correct, and try again.
Place of origin line: 1 character: 1

  • conda activate base
  •  + CategoryInfo:ObjectNotFound:(conda:String)[], CommandNotFoundException
      + Fully QualifiedErrorId—CommandNotFoundException
    
    
 + CategoryInfo:ObjectNotFound:(conda:String)[], CommandNotFoundException
  + Fully QualifiedErrorId—CommandNotFoundException

Cut it out

requests.exceptions.SSLError: HTTPSConnectionPool(host='chromedriver.storage.googleapis.com', port=443): Max retries exceeded with url:/LATEST_RELEASE_93.0.4577(Cause by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")

python python3 pyinstaller

2022-09-30 17:58

1 Answers

After executing the previous Q&A.py file exe by pyinstaller, comment get_ipython().system('pip3install webdriver_manager') or before converting to .py, as stated at the beginning of the error indication .

You will not need those two get_ipython().system(...) lines.
Comment out or delete before converting to .py or processing with PyInstaller.

The function has only been converted from !pip3install... in JupiterLab, which should be unnecessary in JupiterLab if it runs only once in the environment.

!pip3 install-U selenium is the only commenting out error.

The question title pyinstaller myprogram.py --onefile--debug all error is XY problem and does not have anything to do with the first NameError: name 'get_ipython' is not defined [14540] Failed to execute script test 05.


2022-09-30 17:58

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.