簡體   English   中英

獲取python可執行文件或在網絡上運行

[英]getting python executable or running on the web

我目前在本地計算機的Windows 7上運行一個python腳本。

from scipy.optimize import fsolve
import ctypes
import matplotlib.pyplot as plt
import numpy as np
import os, fnmatch
from scipy.signal import argrelextrema
from matplotlib.patches import Rectangle
from reportlab.pdfgen import canvas
from reportlab.lib import colors
from reportlab.lib.units import mm, inch
from reportlab.lib.pagesizes import A3, A4,landscape,letter, inch,portrait
from reportlab.platypus import Image
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Image, Paragraph
import subprocess
import sys

獲取可執行文件是一個挑戰。 即使我這樣做,也存在所有這些.dll文件和依賴項。 現在我在想讓我的代碼在網絡上運行將有多困難? 還是我放棄python而去使用其他東西,例如java,C#,Delphi或? Gui會很不錯,因為當前它是由控制台驅動的。 我的程序如下。 用戶輸入一些東西,然后程序將計算出一些報告給用戶。 然后,用戶將輸入另一個參數,程序將計算其他內容。 產生了表格和圖形,但是圖形不是必需的。 目的是使用戶易於使用。

任何幫助深表感謝。

請參閱在網絡上使用Python 從您的導入中來看,它看起來足夠復雜,以至於需要在后端(服務器端)執行此操作。 因此,我建議堅持使用Python。

我能夠使用cx_Freeze(cx_Freeze-4.3.4-cp27-none-win_amd64)獲得可執行文件。 我正在使用python 2.7.9。 我使用了以下setup.py腳本

import cx_Freeze
import Tkinter as Tk
import ctypes
import numpy
import matplotlib
import os, fnmatch
import sys
import subprocess
import reportlab

base = None

if sys.platform == 'win32':
    base = "Win32GUI"

executables = [
    cx_Freeze.Executable("Test.py", base=base),
]

cx_Freeze.setup(
    name = "Testv1.0",
    options = {"build_exe":{"packages":["Tkinter", "matplotlib"], "includes":["FileDialog"], "excludes":[]}},
    version = "0.1",
    description = "MyApp",
    executables = executables
)

現在,關鍵是在選項中的“包”中添加“ matplotlib”:[“ Tkinter”,“ matplotlib”],並且還具有“ includes”:[“ FileDialog”]。 這解決了我嘗試創建.exe時遇到的所有錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM