为什么我的 tkinter 应用程序会显示一个 node.js 窗口? [英] Why does my tkinter app will show a node.js window?

查看:28
本文介绍了为什么我的 tkinter 应用程序会显示一个 node.js 窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 pyinstaller 来打包一个 .py 文件.

I use pyinstaller to pack a .py file.

然后当我使用一些关于网络爬虫的东西时(我使用请求模块).

Then when I use something about web crawler (I use requests module).

此窗口将快速显示和消失.

This window will show and disappear fastly.

我想说可能是不可思议.运行这个.py文件时不会弹出这个窗口,但是使用pyinstaller打包后,它会弹出这个窗口.

I want to say that it is maybe incredible.It wouldn't pop this window when I run this .py file,but after using pyinstaller to pack it,it will pop this window.

(在另一台电脑上,它没有安装node.js.它也没有弹出这个窗口)

(In another computer,it doesn't install node.js.And it doesn't pop this window)

这是我使用的模块:

from pynput import keyboard
from PIL import Image, ImageTk
import ctypes
from io import BytesIO
import threading
from win10toast import ToastNotifier
import base64
from win32com.shell import shell
import requests
import execjs
import sys
import pythoncom
import getpass
import tkinter
from random import randint
from tkinter import ttk
from tkinter import messagebox
import os
import json
import traceback
from webbrowser import open_new_tab
from tkinter import scrolledtext
import win32con, win32clipboard, win32gui
from PIL.ImageGrab import grabclipboard, grab
from aip import AipOcr
import time

窗口是这样的:

除了卸载node.js,我还能做什么?如何避免这个 node.js 窗口显示?提前致谢.

What should I do except uninstall node.js? How to avoid this node.js window shows? Thanks in advance.

推荐答案

谢谢老哥,acw1668 的建议给了我很多启发.

Thanks bro,acw1668's suggestion enlighten me a lot.

我想说,execjs 模块会运行js代码.如果您的计算机安装了 node.js 并且您为 node.js 设置了 PATH,那么您的默认 js 环境是 node.js(如果您不要安装node.js,那么你的默认js环境是windows系统中的Jscript).

I want to say,execjs module will run js code. And if your computer install node.js and you set PATH for node.js,Then your default js environment is node.js(If you don't install node.js,then your default js environment is Jscript in windows system).

所以如果你不想使用node.js,你应该在python中设置默认的js环境.

So if you doesn't want to use node.js,you should set the default js environment in python.

# change the js environment.
os.environ["EXECJS_RUNTIME"] = "JScript"

# all of environment which execjs support
  PyV8           = "PyV8"
  Node           = "Node"
  JavaScriptCore = "JavaScriptCore"
  SpiderMonkey   = "SpiderMonkey"
  JScript        = "JScript"
  PhantomJS      = "PhantomJS"
  SlimerJS       = "SlimerJS"
  Nashorn        = "Nashorn"

这篇关于为什么我的 tkinter 应用程序会显示一个 node.js 窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆