简体   繁体   English

python自动安装包

[英]python auto install package

i'm facing a problem with python , after i created my script , there is some library i download it and i install it in my ubuntu and i used in my script , now if i give the script to client or any other user maybe he don't know what libraries are there and how to install it , i want an idea to create install.py this file should install all libraries that script need it , is it possible ? 我遇到了python问题,在创建脚本后,有一些库可供下载,然后将其安装在ubuntu中,并在脚本中使用了,现在如果我将该脚本提供给客户端或任何其他用户,也许他不知道那里有什么库以及如何安装它,我想创建一个install.py文件,它应该安装脚本需要它的所有库,这可能吗?

also other question , if i use PYQT is there any way to convert all script to one executable file for mac and windows and linux even they did not install QT ?? 还有另一个问题,如果我使用PYQT,有没有办法将所有脚本转换为适用于Mac和Windows和Linux的一个可执行文件,即使它们没有安装QT?

Thanks advance . 谢谢前进。

Fahad 法哈德

This is a simple bash script for unix that will do your job: 这是一个简单的unix bash脚本,可以完成您的工作:

per module: 每个模块:

#!/bin/sh
while read p; do
  pip install $p
done < requirements.txt

or you can simple pass: 或者您可以简单地通过:

pip install -r requirements.txt

in requirements.txt , enter the modules name: requirements.txt ,输入模块名称:

django
numpy
lxml
#.... so on

You can then run the bash script ./script.sh 然后,您可以运行bash脚本./script.sh

If you want to do the installation of the modules from your python script, you can use setup : 如果要从python脚本安装模块,可以使用setup

from setuptools import setup

setup(
    # ...
    install_requires=['module']
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM