0

I used pyinstaller to make a .exe file out of my working code. However, when I execute the .exe file it returns these errors although they don't show up when I run my code inside VScode.

These are the errors that occur when I open the .exe file

Traceback (most recent call last):
File "main.py", line 7, in <module> 
File "functions.py”, line 43, in inputAll 
File "functions.py", line 14, in scrapeCashAndAccount 
File "requests\sessions.py”, line 555, in get 
File "requests\sessions.py”, line 542, in request 
File "requests\sessions.py”, line 655, in send 
File "requests\adapters.py”, line 416, in send 
File "requests\adapters.py”, line 227, in cert_verify |
Error: Could not find a suitable TLS CA certificate bundle, invalid path: C:\Users\BASSEL~1\AppData\Local\Temp\_MET189
2\certifi\cacert.pem
[4016] Failed to execute script 'main' due to unhandled exception! 

Here is the code, in which I used the requests library.

def scrapeCashAndAccount():
    import requests     #requests info from websites
    import functions
    from bs4 import BeautifulSoup
    session = requests.Session()    # create session
    loginUrl = 'https://investopedia.com/simulator/portfolio/'
    
    payload = {
        'username': 'my_email',
        'password': 'my_password'
    }
    
    authPage = session.get(loginUrl)    # get log in page #if you print(authPage), it will print response of the webpage
    soup = BeautifulSoup(authPage.content, 'html.parser')       #soup is an object #you can print(soup) or print(soup.prettify()) to print the HTM code of the webpage
    
    # get form
    form = soup.find('form')
    
    # get post url
    postUrl = form['action']
    session.post(postUrl, data=payload)     #post insted of get 
    
    tradeUrl = 'https://investopedia.com/simulator/trade/tradestock.aspx'
    page = session.get(tradeUrl)
    soup = BeautifulSoup(page.content, 'html.parser')
    valueAndCash = soup.find_all('td', class_='value num')                             
    #irrelevant stuff

This function is in the file functions.py and I call it in my main.py

bewop
  • 11
  • 3

0 Answers0