Encountering issues with the .exe file after the conversion from .py, specifically receiving the error message: "ModuleNotFoundError: no module named 'selenium'"

Can somebody lend a hand? I'm fairly new to Python and it seems like I might have made a mistake somewhere in my code.

This is the error message I'm getting:

Traceback (most recent call last):
  File "webScrapingTool.py", line 1, in <module>
    from selenium import webdriver
ModuleNotFoundError: No module named 'selenium'

I wrote the code on Ubuntu 22.04, which has Python version 3.10.4 as default. Since I have a dual-boot system, I moved the file to Windows to create a Windows executable since I thought that was necessary. In Windows, I downloaded Python version 3.12.2, which might be contributing to the issue.

I've tried using 'pyinstaller' and 'auto-py-to-exe' on Ubuntu and 'pyinstaller' on Windows, but when I try to create the executable in Windows, I keep encountering the same error message as mentioned above.

Although I worked on a basic project, I'm struggling to figure out how to successfully make my file executable for others to use because I'm still learning Python.

Whenever I attempt to do "pip install cx_freeze" or install the 'requirements.txt' with pip, I get errors like this:

https://pastebin.com/KheA21nM

The issue possibly lies in the difference between where the program was written and where the executable is being created, considering the two different Python versions involved. I came across suggestions regarding 'hiddenimports' in the .spec file, but nothing seems to work. If anyone has any insight into my problem specifically, please share your thoughts. Any help would be greatly appreciated. Thank you!

Answer №1

Issue Description:

The error message specifically points to the following line:

Error: Microsoft Visual C++ 14.0 or a higher version is necessary. Obtain it through "Microsoft C++ Build Tools".

This error indicates that there is a requirement to install or update your existing version of Microsoft Visual C++. This component is essential for converting your python script into a Windows executable.

Furthermore, if you are comfortable with manually importing libraries in pyinstaller, consider doing so for any libraries that cannot be installed automatically by pyinstaller.

Answer №2

Make sure to add the project module before converting it

For example:

pyinstaller.exe --onefile --hidden-import selenium  .\foo.py

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Clicking on the filename in PyQt5 QFileDialog results in the dialog window closing

Using PyQt5 QFileDialog.getOpenFileName, I expected the dialog box to stay open until the "open" button was clicked. However, on my Linux system, the dialog box closes immediately after clicking the file name. On Windows, the box stays open as expected unt ...

Tips on choosing an option from the dropdown menu

Let me outline the steps in my situation: I am adding a new group to the list After adding the group, I need to choose it from the left window and transfer it to the right window. I am uncertain about how to perform the selection. Below is the script I ...

Retrieve browser logs and cause the TestNG test to fail if any severe logs are found in the browser console

I'm currently in the process of developing an automated framework using Selenium, TestNG, and Java. One feature I am working on is checking browser logs during test execution. If any SEVERE logs are detected, I want the corresponding test to be marked ...

What is the best way to pass information to a Python thread that is already running?

In my application, I have a class that runs in separate threads. These threads can run concurrently as daemons, and after a certain time period, some of them need to receive and process messages. How can I achieve this? Here's a snippet from my code: ...

Strategy to implement when a web element is appearing and disappearing twice

I am currently facing a challenge and I need help resolving it. Using Selenium and Helium, I am conducting tests on a web application. During the testing process, the web app displays a screen blocker that appears and disappears twice. I need to wait fo ...

Substitute span elements with blank space or extract content into a separate column using pandas.read_html

I am facing a challenge while scraping Congressional stock trades data from Capitol Trades. The issue arises when trying to extract stock tickers as the column containing them has a span tag that merges company names and tickers. Using pandas.read_html() r ...

Is there a way to select an item from a dropdown menu using Python with Selenium?

I am struggling to select an option from the menu below: <select class="form-control" id="DayBirthDate" name="DayBirthDate"> . <option value="">--</option> <option value="1">1</option> <option value="2">2</option> ...

problems arise when staying logged in is not possible

I've been attempting to extract some email addresses from mdpi.com, but these emails are only accessible to users who are logged in. Unfortunately, my attempts have not been successful so far. When I try to do this while logged out, the following issu ...

Ways to allocate a value among multiple segments using a 1-based approach

Solving the Distribution Problem Given a set of integers values between [1,..,4], the task is to distribute a specific value into segments of different lengths between [1,...,10] on a 1 basis. An illustration of this distribution can be seen in the follo ...

Calling an ajax request to view a JSON pyramid structure

My experience with ajax is limited, so I would appreciate detailed answers. I have a Pyramid application where I need to load information via ajax instead of pre-loading it due to feasibility issues. I want to retrieve the necessary information through a ...

What is the best way to change the color of text within a tkinter text widget?

Is there a way to change the color of specific parts of a tkinter text widget? Here's a snippet of my code for a chat application where I need to distinguish between the sender and the message: T = Text(window, bg="black", fg="white", font=("bold", 1 ...

Utilize the same Selenium drivers across various iterations

I'm attempting to automate browser operations by running two browsers in parallel. I am able to successfully start the drivers, but seem to struggle accessing them using the names driver1 and driver2 or the loop created for the second step. drivers = ...

Generate several JSON files from a CSV file by categorizing items

A CSV file has been provided: year,product,price 2021,P01,50 2022,P03,60 2021,P02,30 The goal is to generate a JSON object for each year containing the list of products like so : { "year": "2021", "products": { &quo ...

Variations in outcomes when sorting an Excel document with the help of pandas and the pywin32 API

I am seeking a way to organize the contents of an Excel file that includes the following data: 1.jpg CC Library - Screen for proxy.png aAd.ai aaa.PSD automation_35.jpg automation_36.jpg automation_37.jpg automation_371.jpg sad.psd sde-Recovered.ai sde-Rec ...

Choosing the primary column in a pandas dataframe

import pandas as pd dataframe1 = pd.DataFrame({'customer' : ['customer2', 'customer1'], 'item1': [12, 13], 'item2' : [3, 28],'item3': [2, 1]}) dataframe2 = pd.DataFrame({'customer' : ...

Automated testing procedures scheduled for optimization

Can I run and test scheduled tests immediately instead of waiting for the set time if the scheduled test time cannot be altered? For instance, imagine having a weekly scheduled test that runs every week on a specific day. What if you need to execute it a ...

tf-idf maintains the feature matrix shape during the transformation of test data

Currently, I am utilizing the technique of tf-idf (text frequency-inverse document frequency) to transform my text input into a feature matrix. Let's assume we have five sentences, each containing 10 different words. To accommodate this, I utilized in ...

Having trouble executing Selenium on replit.com

Previously, I successfully used Selenium on replit.com and it functioned without any issues in other repls. However, when I attempt to create a new repl, I encounter the following error: The code: from selenium import webdriver from selenium.webdriver.chr ...

The error message thrown by bcrypt.checkpw states: "Encoding of Unicode-objects is required before proceeding with

When using bcrypt.checkpw to compare an unencrypted password with a hashed password stored in the credential database, I encountered an issue: An error occurred: TypeError: Unicode-objects must be encoded before checking How can this problem be resolve ...

Automating web page login with Python Selenium

Recently I started working with Python and Selenium to create an automated login script for checking appointment availability. I have encountered a problem with my code where it throws an exception at the "Button click failed" line when run without breakpo ...