简体   繁体   English

如何使我的python脚本可执行

[英]How to make my python script executable

I am trying to make my script executable. 我正在尝试使脚本可执行。 I used pyinstaller to transform my script into an 'exe'. 我使用pyinstaller将脚本转换为“ exe”。 However, after I transformed it when I double click the 'exe' file it opens a command window and closes it within 0.5 seconds. 但是,当我双击“ exe”文件进行转换后,它会打开一个命令窗口并在0.5秒内将其关闭。

My script creates a class that executes functions. 我的脚本创建了一个执行功能的类。 The purpose of the script is automatically generate a report from a website, process the report, and export it to a database. 该脚本的目的是从网站自动生成报告,处理该报告,并将其导出到数据库。

My last few lines prompts the user to input their username, password, month, and year. 最后几行提示用户输入用户名,密码,月份和年份。 Then it runs the class functions with the prompted inputs. 然后,使用提示的输入运行类函数。

Is there something missing in my script or am I writing it wrong? 脚本中是否缺少某些内容,或者我写错了吗?

I am using Windows 7, pycharm as my IDE, my project interpreter is anaconda/python 2.7. 我使用Windows 7,pycharm作为我的IDE,我的项目解释器是anaconda / python 2.7。

Here is my script, it does not contain the class function because it is too long. 这是我的脚本,它不包含类函数,因为它太长了。 But, everything works fine when I run it in pycharm. 但是,当我在pycharm中运行时,一切正常。

import os
import sys
import pandas as pd
import datetime as dt
import pyodbc
import sqlalchemy
import time
import datetime as dt
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select

class Cybersource(object):...

username = raw_input("username: ")
password = raw_input("password: ")
month = raw_input("month (example: 07): ")
year = raw_input("year (example: 2015): ")

test = Cybersource(username,password,month,year)
test.scraper()
test.rename()
test.clean()

I want to make my script executable so I can run it faster without opening pycharm or hand it off to other people. 我想使脚本可执行,这样我可以更快地运行它而无需打开pycharm或将其交给其他人。

Please let me know if there are any questions. 如有任何问题,请告诉我。

Thanks 谢谢

可以从cmd运行您的script.exe(不能双击)并发布确切的错误吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM