首页 |  我的博客 |  查看该博主内容分类 | 

如何获得一个纯净的嵌入包python-embed环境,不用打包,即使没有安装python环境也可以直接分享给朋友运行?

步骤

  1. 下载python-3.9.7-embed-amd64.zip(点我32bit/64bit),其他版本请到官网自行下载;

  2. 解压python-3.9.7-embed-amd64.zip到合适的位置;

  3. 右键我get-pip.py,选择链接另存为,放入解压好的根目录; --资料:get-pip.py官方说明

  4. 在解压后的根目录执行python get-pip.py

  5. 修改根目录python39._pth文件,将import site前的#号去掉,即让其生效不注释;

  6. 进入.\Scripts,pip正常install安装需要的包。

    如果用到tkinter模块(可选)

    tkinter是内置包无法下载安装,可以复制安好的python环境的下列文件到指定位置即可:

    • /tcl/DLLs/_tkinter.pyd/DLLs/tcl86t.dll/DLLs/tk86t.dll 拷贝到 根目录/
    • /Lib/tkinter 拷到 /Lib/site-packages/

使用

dos(命令行)进入解压包的根目录,执行python 你的py脚本文件路径即可,可以写成bat脚本,直接打开就能运行,不用输命令:
start.bat

python 你的py脚本文件路径

保存后,双击打开start.bat就能运行脚本。

提示:文件可以新建txt文本,写入代码后,再改名即可。

参考资料

  1. Python embeddable zip: install Tkinter
  2. 安装嵌入式(绿色版、免安装)Python——Embeddable Python的开发环境搭建
posted @ 2023-03-14 23:08  Z哎呀  阅读(461)  评论(0编辑  收藏  举报
// let homeEle = document.querySelector('body') // homeEle.setAttribute('id', 'particles-js') // /* ---- particles.js config ---- */ // particlesJS("particles-js", { // "particles": { // "number": { // "value": 380, // "density": { // "enable": true, // "value_area": 800 // } // }, // "color": { // "value": "#ffffff" // }, // "shape": { // "type": "circle", // "stroke": { // "width": 0, // "color": "#000000" // }, // "polygon": { // "nb_sides": 5 // }, // "image": { // "src": "img/github.svg", // "width": 100, // "height": 100 // } // }, // "opacity": { // "value": 0.5, // "random": false, // "anim": { // "enable": false, // "speed": 1, // "opacity_min": 0.1, // "sync": false // } // }, // "size": { // "value": 3, // "random": true, // "anim": { // "enable": false, // "speed": 40, // "size_min": 0.1, // "sync": false // } // }, // "line_linked": { // "enable": true, // "distance": 150, // "color": "#ffffff", // "opacity": 0.4, // "width": 1 // }, // "move": { // "enable": true, // "speed": 6, // "direction": "none", // "random": false, // "straight": false, // "out_mode": "out", // "bounce": false, // "attract": { // "enable": false, // "rotateX": 600, // "rotateY": 1200 // } // } // }, // "interactivity": { // "detect_on": "canvas", // "events": { // "onhover": { // "enable": true, // "mode": "grab" // }, // "onclick": { // "enable": true, // "mode": "push" // }, // "resize": true // }, // "modes": { // "grab": { // "distance": 140, // "line_linked": { // "opacity": 1 // } // }, // "bubble": { // "distance": 400, // "size": 40, // "duration": 2, // "opacity": 8, // "speed": 3 // }, // "repulse": { // "distance": 200, // "duration": 0.4 // }, // "push": { // "particles_nb": 4 // }, // "remove": { // "particles_nb": 2 // } // } // }, // "retina_detect": true // }); // var count_particles, stats, update; // stats = new Stats; // stats.setMode(0); // stats.domElement.style.position = 'absolute'; // stats.domElement.style.left = '0px'; // stats.domElement.style.top = '0px'; // document.body.appendChild(stats.domElement); // count_particles = document.querySelector('.js-count-particles'); // update = function() { // stats.begin(); // stats.end(); // if (window.pJSDom[0].pJS.particles && window.pJSDom[0].pJS.particles.array) { // count_particles.innerText = window.pJSDom[0].pJS.particles.array.length; // } // requestAnimationFrame(update); // }; // requestAnimationFrame(update);