buchizaodian

1.安装 pyinstaller

pip install pyinstaller 

2.创建文件

pyinstaller yourprogram.py

试了半天总是报

TypeError: expected str, bytes or os.PathLike object, not NoneType

用的python3.7. 之后换成python3.6就好了

 

后面多出了一个窗体 加 -w 去掉窗体

 

运行在ubunto

sudo apt-get install wine

选中exe 右键用wine打开

 

----------------------

发布

1. 为模块创建一个文件夹,把chart2.py 复制到该文件夹下,假设文件夹名为chart2

2.在该文件夹下创建一个叫setup.py的文件

这个文件包含有关发布的元数据,

from distutils.core import setup
setup(
    name=\'chart2\',
    version=\'1.0.0\',
    py_modules=[\'chart2\'],
    author=\'meng\',
    author_email=\'meng.com\',
    url=\'http://www.meng.com\',
    description=\'web\',
)

3.构建一个发布文件

 在chart2文件夹下打开cmd

运行

#安装python.exe的路径+
C:\Python36\python.exe setup.py sdist

 

 

多出一个文件夹dist和一个MANIFEST文件

dist文件夹中生成一个.tar.gz文件

 

4.安装到python本地副本

在chart2 文件夹下执行

python setup.py install

 

 

 成功安装到了python中 ,在C:\Python36\Lib\site-packages文件夹下生成了两个文件 chart2.py和 chart2-1.0.0-py3.6.egg-info

 

5.导入并使用

 

>>> import chart2

使用时会报错, 因为编译器不能识别它使用的哪个命名空间的函数。

 所以需要在函数前加上命名空间名

 

使用可选参数

分类:

技术点:

相关文章:

  • 2021-11-23
  • 2021-11-06
  • 2021-09-25
  • 2021-11-23
  • 2021-09-09
  • 2021-08-18
  • 2021-10-06
  • 2021-11-04
猜你喜欢
  • 2021-11-23
  • 2021-11-23
  • 2021-11-23
  • 2021-11-20
  • 2021-11-23
  • 2021-11-23
  • 2022-02-03
相关资源
相似解决方案