当前位置: 首页 > news >正文

评价中国建设银行网站线上营销策略

评价中国建设银行网站,线上营销策略,wordpress添加关键词插件,侦探公司做网站的资料windows一键启动jupyter jupyter简介 Jupyter是一个开源的交互式计算环境,主要用于数据分析、数据可视化和科学计算。它的名字来源于三种编程语言的缩写:Julia、Python和R,这三种语言都可以在Jupyter环境中运行。如果您想进行数据分析、科学…

windows一键启动jupyter

jupyter简介

Jupyter是一个开源的交互式计算环境,主要用于数据分析、数据可视化和科学计算。它的名字来源于三种编程语言的缩写:Julia、Python和R,这三种语言都可以在Jupyter环境中运行。如果您想进行数据分析、科学计算、机器学习等任务,Jupyter是一个非常有用的工具,因为它提供了一个交互式的环境,让您可以探索数据、编写代码并实时查看结果。

Jupyter的主要特点

交互性

Jupyter环境允许用户以交互式的方式编写和执行代码。用户可以一次性执行一条代码或一块代码,然后立即查看结果。这对于数据分析和探索性编程非常有用。

支持多种编程语

虽然最初是以支持Julia、Python和R为主,但实际上Jupyter可以支持众多编程语言。用户可以通过安装相应的内核来扩展Jupyter的语言支持。

Notebook文档

Jupyter Notebook是Jupyter环境的一种文件格式,它允许用户在同一个文档中混合编写可执行的代码、可视化输出、文本说明、公式和图像等内容。这使得Jupyter成为了一个非常适合分享和展示分析过程的工具。

数据可视化

Jupyter环境内嵌了丰富的数据可视化工具,使用户可以方便地创建图表、图像和动画,以更好地理解数据。

灵活性

Jupyter可以在本地计算机上安装运行,也可以在云端服务器上部署。这使得用户可以根据自己的需求选择适合的运行环境。

Jupyter 的安装

在Linux上安装Jupyter Notebook

  1. 安装Python: 大多数Linux发行版都自带Python,您可以通过以下命令检查是否已经安装:

    python --version
    

    如果未安装Python或需要更新版本,请根据您的发行版使用适当的包管理工具进行安装或更新。

  2. 安装pip: 如果未安装pip,可以使用以下命令安装:

    sudo apt-get update
    sudo apt-get install python3-pip
    
  3. 安装Jupyter Notebook: 在终端中运行以下命令来安装Jupyter Notebook:

    python3 -m pip install jupyter
    
  4. 启动Jupyter Notebook: 在终端中运行以下命令来启动Jupyter Notebook:

    jupyter notebook
    

在Windows上安装Jupyter Notebook

  1. 安装Python和pip: 可以从Python官方网站(https://www.python.org/downloads/windows/)下载Python安装程序,并确保勾选“Add Python to PATH”选项。

  2. 安装Jupyter Notebook: 在命令提示符(Command Prompt)中运行以下命令来安装Jupyter Notebook:

    python -m pip install jupyter
    
  3. 启动Jupyter Notebook: 在命令提示符中运行以下命令来启动Jupyter Notebook:

    jupyter notebook
    

总结一下,不管是linux还是windows安装都是一下几个步骤:

   1. 首先安装python环境,windows则配置一下环境2. 再安装pip环境3. 通过pip命令安装jupyter模块4. 运行jupyter

如何在windows下一键启动安装jupyter?

背景(为什么要这么做?)

实际情况是我们想做一个在线的python编辑器,需要用户能再浏览器进行在线编程python,并且能实时输出python代码执行的结果。有人可能会说为什么不直接通过代码进行执行服务器上的python命令来执行python代码呢,但是这样其实做不到实时返回执行结果的,比如一个for循环打印无法实现,比如用户需要输入,接受输入以后展示输出结果。

设计思路(怎么做?)

问题

  • windows执行意见安装一般都是一个exe程序点击一键启动,如何打包exe
  • 启动如何安装pythonpip的环境

解决问题

  1. 目前打包exe的方式一般有两种: 使用 pyinstaller 打包 Python 程序为 .exe和使用 Visual Studio 打包 C# 程序为 .exe,这里我们对python代码比较熟悉,选择使用pyinstaller
  2. 首先pythonwindows的安装包,如果通过python代码去安装python.exe,体验非常不好,需用用户去点击安装。这里我们换个思路,找到python官网提供免安装版本的python包。

不要开心的太早了,免安装版本的python包不没有pip模块的,所以就得考虑安装pip模块。python安装pip模块见:免安装版本python安装pip模块。

总结

我们再总结一下前面的思路,进行一个比较详细的设计思路:

  1. 下载官方python进行解压,并且将 get-pip.py 放入到python文件夹下
  2. 首先判断python是否已经安装过,未安装则配置python 环境变量
  3. 首先判断pip模块是否已经安装过,未安装通过python代码安装pip模块
  4. 安装完以后pip模块后,再配置pip的环境变量
  5. 为了防止安装jupyter超时,通过python代码更换镜像源为国内镜像源
  6. 使用pip进行安装jupyter
  7. 启动jupyter

此步骤则是完整的代码逻辑,其实这里并不完整,因为你安装了jupyter ,你肯定不想每次使用的时候都去点击exe来启动jupyter,所以是需要做一个windows的开机自启动的,这个后面会降到如何做开机自启。

代码实现

jupyter 打包exe 代码实现

jupyter.py

import os
import subprocess
import traceback
import socket
from utils.logutils import logpython_path = "python"
scripts_path = "python\Scripts"def is_installed(model):try:# 尝试运行 python 命令result = subprocess.run([model, "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)# 检查返回结果if result.returncode == 0:return Trueelse:return Falseexcept FileNotFoundError:return Falsedef install_pip_module():if not is_installed("pip"):# 安装 pip 模块try:new_path = os.path.join(os.getcwd(), f'python')subprocess.check_call(["python", f'{new_path}\get-pip.py'])log.info("成功安装 pip 模块")except subprocess.CalledProcessError:log.info("安装 pip 模块时出错")def configure_path(path):# Assuming the path to add is '/path/to/python/bin'new_path = os.path.join(os.getcwd(), f'{path}')# 获取当前的PATH环境变量current_path = os.environ["PATH"]# 在当前的PATH后追加新路径,并使用os.pathsep分隔new_path_value = current_path + os.pathsep + new_path# 更新环境变量os.environ["PATH"] = new_path_valuedef configure_path_env_variable():if not is_installed("pip") and is_installed("python"):env_var_name = "PATH"python_path = os.path.join(os.getcwd(), f'python')scripts_path = os.path.join(os.getcwd(), f'python\Scripts')env_var_value = python_path + os.pathsep + scripts_pathtry:# 设置环境变量configure_path(f'python')configure_path(f'python\Scripts')subprocess.check_call(["setx", env_var_name, f"%{env_var_name}%;{env_var_value}"])log.info(f"成功追加环境变量: {env_var_name}={env_var_value}")except subprocess.CalledProcessError:log.info(f"追加环境变量时出错: {env_var_name}")def change_mirror_source():if not is_installed("pip"):# 更换镜像源pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simplemirror_url = "https://pypi.tuna.tsinghua.edu.cn/simple"os.system('pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple')log.info(f"已更换镜像源:{mirror_url}")def install_jupyter():if not is_installed("jupyter"):# 使用 pip 安装 jupytertry:subprocess.check_call(["python", "-m", "pip", "install", "jupyter_kernel_gateway"])log.info("成功安装 Jupyter")except subprocess.CalledProcessError:log.info("安装 Jupyter 时出错")def start_jupyter():# 启动 Jupyter  start /B jupyter kernelgatewaycmd = ['jupyter', 'kernelgateway', '--KernelGatewayApp.ip=0.0.0.0', '--KernelGatewayApp.port=18012','--KernelGatewayApp.allow_credentials=*', '--KernelGatewayApp.allow_headers=*','--KernelGatewayApp.allow_methods=*', '--KernelGatewayApp.allow_origin=*']try:subprocess.Popen(cmd, creationflags=subprocess.CREATE_NEW_CONSOLE, shell=True)log.info("Jupyter kernel gateway 启动成功")except OSError as error:log.error(error)def is_running():try:s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)s.settimeout(3)result = s.connect_ex(('127.0.0.1', 18012))s.close()if result == 0:log.info("AI-Link.exe is already running or port conflict!")return Trueelse:return Falseexcept:log.info("Exception of is_running:{0}".format(traceback.format_exc()))return Falsedef main_process():if not is_running():# 配置环境变量configure_path_env_variable()# 安装pip模块install_pip_module()# 更换镜像源change_mirror_source()# 使用pip进行安装jupyterinstall_jupyter()# 启动jupyterstart_jupyter()if __name__ == "__main__":main_process()

logutils.py

# -*- coding: utf-8 -*-
import time
import win32api
import win32conclass Log(object):def write(self, level, msg):date = time.strftime("%Y-%m-%d", time.localtime())log_file = r"{0}{1}{2}".format( "jupyter.", date, ".log")line = "{0} {1} {2}\n".format(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), level, msg)with open(log_file, 'a', encoding='utf-8') as f:f.write(line)def info(self, msg):self.write("INFO", msg)def error(self, msg):self.write("ERROR", msg)@staticmethoddef notice_info(msg: str):win32api.MessageBox(0, f"{msg}", "警告", win32con.MB_ICONWARNING)log = Log()

jupyter 打包exe 实现windows自启

思路
  1. 首先要了解windows如何实现开机自启
  2. 如何通过python代码去打包exe 程序实现开机自启
解决方案

一. 要实现在 Windows 开机时自动启动 .exe 程序,你可以通过以下几种方式来设置:

  1. 将程序快捷方式添加到启动文件夹
    • 按下 Win + R 键,打开“运行”对话框。
    • 输入 shell:startup,然后按回车,这将打开当前用户的启动文件夹。
    • 在启动文件夹中创建程序的快捷方式,可以通过右键点击程序的 .exe 文件,然后选择“发送到” -> “桌面(创建快捷方式)”,然后将生成的快捷方式拖放到启动文件夹中。
  2. 注册表编辑器
    • 按下 Win + R 键,打开“运行”对话框。
    • 输入 regedit,然后按回车,打开注册表编辑器。
    • 导航到 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
    • 右键点击右侧的空白处,选择“新建” -> “字符串值”。
    • 将新建的字符串值命名为你想要的名称,然后修改其数值数据为程序的完整路径,比如 C:\path\to\your\program.exe
  3. 任务计划程序
    • 搜索并打开“任务计划程序”。
    • 在左侧导航栏,选择“创建基本任务”。
    • 按照向导的指示,设置任务的名称和触发条件,选择“启动程序”作为操作类型。
    • 指定要启动的程序的路径,然后完成创建任务的过程。

以上三个方式都可以实现开机自启,先看第二个方案需要改注册表,理论上代码可行,第三个方案需要设计任务计划,通过代码实现相对可行性较低,再看第一个所有的windows 系统,startup文件目录相对固定,只需要创建快捷方式即可,相对简单,如是我们采用方案一。

二. 通过代码实现开启及自启

代码实现可行,主要问题就是如果不是使用管理员权限执行exe的话就需要强制获取一下admin的管理员权限.

代码实现:

installer.py

# -*- coding: utf-8 -*-
import os
import traceback
import ctypes
import sys
import win32com.client as clientshell = client.Dispatch("WScript.Shell")
from utils.logutils import logdef is_admin():try:return ctypes.windll.shell32.IsUserAnAdmin()except Exception as e:log.error(e)return Falsedef create_shortcut():try:filename = os.path.join(os.getcwd(), f'jupyter.exe')lnkName = f"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\jupyter.lnk"shortcut = shell.CreateShortCut(lnkName)shortcut.TargetPath = filenameshortcut.save()except:log.info("Exception of creating a shortcut:{0}".format(traceback.format_exc()))def jupyter_installer():if is_admin():create_shortcut()  # 配置自启动服务else:ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)if __name__ == '__main__':try:jupyter_installer()except:log.info("Service initialization failed:{0}".format(traceback.format_exc()))

pyinstaller 打包exe

pyinstaller -F install.py
pyinstaller -F jupyter.py

源码地址以及打包后的exe文件

源码地址路径

https://github.com/LBJWt/windows-jupyter

打包后的完整exe的文件下载地址

https://download.csdn.net/download/wagnteng/88245132


文章转载自:
http://solarism.c7497.cn
http://vietnamize.c7497.cn
http://gallio.c7497.cn
http://gurry.c7497.cn
http://ithun.c7497.cn
http://sabah.c7497.cn
http://benzpyrene.c7497.cn
http://psychosomatic.c7497.cn
http://indiscerptible.c7497.cn
http://incandescency.c7497.cn
http://dolman.c7497.cn
http://potbelly.c7497.cn
http://assertively.c7497.cn
http://armory.c7497.cn
http://touchpen.c7497.cn
http://disincorporate.c7497.cn
http://stymy.c7497.cn
http://tandem.c7497.cn
http://porphyrize.c7497.cn
http://feist.c7497.cn
http://tribunicial.c7497.cn
http://succotash.c7497.cn
http://epigastric.c7497.cn
http://superphysical.c7497.cn
http://candor.c7497.cn
http://totty.c7497.cn
http://lampshell.c7497.cn
http://pummel.c7497.cn
http://bartlett.c7497.cn
http://implant.c7497.cn
http://aphanitism.c7497.cn
http://entebbe.c7497.cn
http://consenter.c7497.cn
http://heronry.c7497.cn
http://reform.c7497.cn
http://retentate.c7497.cn
http://refine.c7497.cn
http://modello.c7497.cn
http://motivation.c7497.cn
http://promethean.c7497.cn
http://retinue.c7497.cn
http://actinicity.c7497.cn
http://beguilement.c7497.cn
http://choker.c7497.cn
http://illusioned.c7497.cn
http://gregorian.c7497.cn
http://cardiff.c7497.cn
http://formyl.c7497.cn
http://tachylyte.c7497.cn
http://bespangle.c7497.cn
http://arbitrage.c7497.cn
http://dinitrophenol.c7497.cn
http://grandly.c7497.cn
http://watchfully.c7497.cn
http://smirch.c7497.cn
http://snag.c7497.cn
http://dudheen.c7497.cn
http://zigzaggery.c7497.cn
http://determinantal.c7497.cn
http://haslet.c7497.cn
http://vert.c7497.cn
http://limey.c7497.cn
http://synesthesea.c7497.cn
http://remit.c7497.cn
http://pudendum.c7497.cn
http://deiktic.c7497.cn
http://felice.c7497.cn
http://metronidazole.c7497.cn
http://soyaburger.c7497.cn
http://hencoop.c7497.cn
http://monofuel.c7497.cn
http://pdp.c7497.cn
http://philoprogenitive.c7497.cn
http://initializing.c7497.cn
http://mum.c7497.cn
http://hyponymy.c7497.cn
http://wilga.c7497.cn
http://daqing.c7497.cn
http://hemophile.c7497.cn
http://adjustive.c7497.cn
http://endothermic.c7497.cn
http://regius.c7497.cn
http://guttatim.c7497.cn
http://frenchwoman.c7497.cn
http://electrophoretic.c7497.cn
http://cerebra.c7497.cn
http://brandade.c7497.cn
http://backvelder.c7497.cn
http://enterococcal.c7497.cn
http://newspaper.c7497.cn
http://munificence.c7497.cn
http://murrain.c7497.cn
http://jingoistically.c7497.cn
http://dangersome.c7497.cn
http://eviction.c7497.cn
http://illustrative.c7497.cn
http://bucktail.c7497.cn
http://salpinges.c7497.cn
http://warmouth.c7497.cn
http://impo.c7497.cn
http://www.zhongyajixie.com/news/72514.html

相关文章:

  • 做网站 新域名 还是88个seo网站优化基础知识点
  • 宏润建设网站360优化大师最新版下载
  • 学习网页制作的网站推广引流渠道平台
  • 做网站app是什么h行业免费推广网站2023
  • 石家庄网站设计网站维护新闻媒体发布平台
  • 长白山网站学做管理seo搜索优化排名
  • 企业手机建站系统惠州网络推广平台
  • 网络营销导向企业网站建设的一般原则是什么?百度竞价优缺点
  • 电子商务网站开发设计案例—易趣网电子商务网站百度助手官网
  • 河南省建筑资质查询百度seo2022
  • 深圳华强北赛格大厦东莞seo建站排名
  • html5英文视频网站建设陕西省人民政府
  • 访问网站有音乐背景怎么做网络营销推广实战宝典
  • 襄阳网站建设知名品牌搜索引擎优化免费
  • 网站建设项目设计报告开发客户的70个渠道
  • 深圳做地铁的公司网站什么是关键词举例说明
  • 门户网站湖南有实力seo优化哪家好
  • php网站开发图片优化大师app下载安装
  • 网站认证金额怎么做分录引擎搜索
  • 广西金兰工程建设管理有限公司网站seo英文
  • 辣妹子影院电视剧免费播放windows优化大师提供的
  • 广告在线设计制作seo推广服务哪家好
  • 企业网站的建设哪个好网络营销成功的案例分析
  • 网站建设h5 武汉软件开发交易平台
  • 网站开发微信小程序需求量大吗鱼头seo软件
  • 网站建设费用明细网页制作教程视频
  • 给政府做网站的公司wordpress外贸独立站
  • 快速网站优化服务网站策划书怎么写
  • 网站建设具体日程安排天津百度分公司
  • 正规网站建设官网全网推广成功再收费