Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 日韩电影中文字幕在线网站,欧美精品免费在线,一级毛片在线播放

          整合營銷服務商

          電腦端+手機端+微信端=數據同步管理

          免費咨詢熱線:

          Python打包成exe的方法介紹

          Python打包成exe的方法介紹

          ython的開發效率非常的高,但是當我們用python寫一些小工具需要給用戶使用的時候,用戶大多數是沒有安裝python的。
          本文介紹兩種python的打包方案,使用pyinstaller和nuitka打包成exe(或其他操作系統的可執行程序)后便可以直接分發給用戶,無需用戶安裝python。

          示例程序

          這邊使用pyqt6來做演示,使用pyqt6我們可以快速創建一個跨平臺原生gui程序,也是這兩個打包工具最常用的場景之一。

          安裝pyqt6庫:

          pip install pyqt6

          創建mainwindow.py,寫入以下內容:

          import sys
          from PyQt6.QtWidgets import QWidget, QToolTip, QPushButton, QApplication
          from PyQt6.QtGui import QFont
          
          class Example(QWidget):
              def __init__(self):
                  super().__init__()
                  self.initUI()
          
              def initUI(self):
                  QToolTip.setFont(QFont("SansSerif", 10))
                  self.setToolTip("This is a <b>QWidget</b> widget")
                  btn=QPushButton("Button", self)
                  btn.setToolTip("This is a <b>QPushButton</b> widget")
                  btn.resize(btn.sizeHint())
                  btn.move(50, 50)
                  self.setGeometry(300, 300, 300, 200)
                  self.setWindowTitle("Tooltips")
                  self.show()
          
          def main():
          
              app=QApplication(sys.argv)
              ex=Example()
              sys.exit(app.exec())
          
          if __name__=="__main__":
              main()

          執行程序:

          python mainwindow.py

          執行后會打開一個demo窗口:

          pyinstaller

          安裝:

          pip installer pyinstaller

          打包為文件夾:

          pyinstaller -D -w ./mainwindow.py

          該命令會打包exe、python解釋器和其他dll到 dist/mainwindow 中。

          打包為單個exe:

          pyinstaller -F -w ./mainwindow.py

          該命令只輸出一個mainwindow.exe到dist目錄中,打開 dist/mainwindow.exe 時會將所有依賴項解壓到臨時目錄中然后運行,當然這一步對用戶是無感的。
          使用這兩種方法生成的exe都可以直接分發給用戶,pyinstaller是大多數時候的首選項,方便快捷。不過pyinstaller最大的問題是無法隱藏源碼以及效率稍微慢一些。

          nuitka

          nuitka使用c語言編譯器將python源碼及模塊編譯成原生二進制,據此可以做到完全隱藏源碼,同時提高運行效率。
          安裝:

          pip installer nuitka

          安裝的時候nuitka會根據我們的操作系統選擇最佳的c語言編譯器。

          打包為文件夾:

          python -m nuitka mainwindow.py --standalone --enable-plugin=pyqt6 --disable-console

          該命令會輸出 mainwindow.exe 到當前目錄下,我們可以直接拿來執行或者分發給其他用戶。
          需要注意的是這種方式也是解壓到臨時目錄中,效率相比打包成文件夾慢一點,但是整體還是比 pyinstaller 快。

          原文鏈接:https://juejin.cn/post/7369876349488775207

          本說明

          jdk:1.8

          scala:2.11.8

          spark:2.3.0

          hadoop:2.8.3

          環境準備

          jdk配置

          1、配置JAVA_HOME與Path:

          Path

          2、驗證配置:

          scala安裝與配置

          1、scala下載:

          訪問官方地址http://www.scala-lang.org/download/2.11.8.html

          2、配置Path:

          3、驗證配置:

          Spark安裝與配置

          1、spark下載:

          訪問官方地址http://spark.apache.org/downloads.html

          選中官方推薦的地址即可下載,其他地址也可用(建議采用迅雷等下載工具下載,速度比較會快很多)

          2、解壓至D盤;

          3、配置Path:

          4、通過spark-shell進入Spark的交互式命令行模式:

          如上,可以看到對應的spark、scala、java版本,同時也看到了異常信息,該異常信息是由于hadoop導致的,下面來配置hadoop。

          Hadoop安裝與配置

          1、hadoop下載

          訪問官方http://hadoop.apache.org/releases.html

          進入下載頁,如下建議地址(同樣建議用迅雷等下載工具下載,速度更快)

          2、解壓至

          3、配置HADOOP_HOME&Path:

          path:

          4、winutils下載:https://github.com/steveloughran/winutils

          下載對應版本的bin目錄直接替換本地bin目錄即可。

          5、此時繼續spark-shell進入spark命令行交互模式:

          此時即不會出現上述的異常提示。

          6、訪問控制臺中的webui如下:

          、前言

          本文實現RAR批量解壓的功能,通過python腳本調用WinRAR.exe解壓文件時似乎不會再有廣告框彈出。

          二、實現

          通過python調用WinRAR.exe程序實現RAR文件的批量解壓,代碼如下:

          import argparse
          import os
          
          class RarExtractor:
              def __init__(self, in_dir="./", out_dir="./", pwds=None, exe=None):
                  self.in_dir=in_dir
                  self.out_dir=out_dir
                  self.pwds=pwds if pwds else ['1234']
                  self.exe='"%s"' % exe if exe else '"C:\Program Files\WinRAR\WinRAR.exe"'
          
              def extract_files(self, pwds, file_path, dst):
                  if not os.path.exists(dst):
                      os.mkdir(dst)
          
                  if os.path.isdir(dst) and os.path.isfile(file_path):
                      try:
                          for pwd in pwds:
                              extract_cmd=r'%s x -y -p%s %s %s' % (self.exe, pwd, file_path, dst)
                              if os.system(extract_cmd)==0:
                                  print("Extract %s OK." % file_path)
                                  return 0
                              else:
                                  print("Extract %s failed." % file_path)
                                  return -1
                      except RuntimeError:
                          print("error")
                          return -1
                  else:
                      print('File not exist')
                      return -1
          
              def extract_all_rar(self):
                  for root, dirs, files in os.walk(self.in_dir):
                      for f in files:
                          (filename, ext)=os.path.splitext(f)
                          if ext=='.rar':
                              file_path=os.path.join(root, f)
                              print(file_path)
                              self.extract_files(self.pwds, file_path, os.path.join(self.out_dir, filename))
          
          def _parse_options():
              parser=argparse.ArgumentParser()
              parser.add_argument("--in_dir", action="store", dest="in_dir", required=True, help="Rar files dir")
              parser.add_argument("--out_dir", action="store", dest="out_dir", required=False, help="Extracted file dir")
              parser.add_argument("--pwds", nargs='+', action="store", dest="pwds", required=False,
                                  help="Password list to extract Rar: --pwds 1111 2222 3333")
              parser.add_argument("--exe", action="store", dest="exe", required=False, help="RAR exe install path")
              return parser.parse_args()
          
          if __name__=='__main__':
              options=_parse_options()
              extractor=RarExtractor(options.in_dir, options.out_dir, options.pwds, options.exe)
              extractor.extract_all_rar()
          

          需要傳入的參數為:

          • --in_dir RAR文件所在目錄,默認是當前目錄
          • --out_dir 指定解壓后輸出的目錄,默認是當前目錄
          • --pwds 如果RAR是加密的,則需要指定解壓密碼,可以指定多個密碼,以空格隔開
          • --exe 指定WinRAR.exe所在的目錄,默認是"C:\Program Files\WinRAR\WinRAR.exe"

          三、測試

          在目錄D:\rar_test\下新建3個txt文件,使用RAR加密壓縮,密碼為1024、2048和4096。

          通過以下命令測試:

          python rar_extractor.py --in_dir D:\rar_test\ --out_dir D:\rar_test\ --pwds 1024 2048 4096 --exe "C:\Program Files\WinRAR\WinRAR.exe"

          主站蜘蛛池模板: 青娱乐国产官网极品一区 | 中文字幕日韩一区| AV无码精品一区二区三区| 久久精品国产第一区二区| 波多野结衣一区二区三区| 久久久久无码国产精品一区| 视频在线观看一区二区三区| 在线视频精品一区| 亲子乱av一区区三区40岁| 无码人妻精品一区二区三区在线| 国产免费一区二区三区免费视频| 国产在线精品观看一区| 日韩久久精品一区二区三区| 成人h动漫精品一区二区无码| 亚洲日本一区二区三区| 一区二区乱子伦在线播放| 国产成人高清视频一区二区| 无码人妻一区二区三区精品视频| 国产精品一区二区资源| 日韩精品一区在线| 视频一区二区中文字幕| 日韩毛片一区视频免费| 红杏亚洲影院一区二区三区| 一区二区三区在线免费| 国产福利一区二区在线视频| 无码国产精品一区二区免费16| 国产一区二区三区免费视频| 亚洲av无码片vr一区二区三区| 亚洲字幕AV一区二区三区四区| 久久久国产精品亚洲一区| 亚洲国产精品一区二区第一页 | 亚洲一区二区久久| 一区高清大胆人体| 亚洲午夜一区二区三区| 亚洲日韩中文字幕一区| 国产成人综合亚洲一区| 99精品国产高清一区二区三区 | 国产成人精品视频一区二区不卡| 性无码免费一区二区三区在线| 中文字幕日韩一区| 立川理惠在线播放一区|