#How I can send my python file to my friends?

6 messages · Page 1 of 1 (latest)

grand saddle
#

I created a project and I want to send it to people to be able to run it, i tried turning it to exe but it crashed my PC, and when I tried to send the whole project with source code it worked for me but other people had different errors. can someone help me?

grand saddle
#

seems like it requires them to download the modules

stuck terrace
#

Recommendation use virtual environments for your python projects.

Run in terminal: pip freeze

Copy the pip packages listed for your project into a *.txt file. E.g requirements.txt

Send the project to your friends with requirements.txt file

Ensure they are in the same directory as the project

If they have virtual environments tell them to switch in to them

Their terminals run: pip install -r requiremrnts.txt

All depedencies for the project should be installed and they can run it

deep meadow
grand saddle
#

I fixed the problem, turns out they didn't have the libraries installed, so I made a script called install that installs every library automatically for them, they have to run it before starting. Here is the script:

import subprocess
import sys

def install(package):
    subprocess.check_call([sys.executable, "-m", "pip", "install", package])

# List of the libraries needed
dependencies = [
    'pyautogui',
    'pyautoit',
    'keyboard',
    'pynput',
    'tk',
    'requests',
    'pygetwindow',
    'numpy',
    'pillow',
    'multiprocessing',
    'ctypes',
    'webbrowser',
    'configparser',
]

if __name__ == "__main__":
    for package in dependencies:
        try:
            __import__(package)
        except ImportError:
            install(package)