[root@wode006 tools]# wget https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.5.zip
在上一篇博客中,我们介绍了如何使用pyinstaller将python项目打包成一个可执行文件,并且放在系统目录下,让系统用户可以直接识别到我们构造的项目。而python项目中常见的setup.py其实也是在执行类似的构建的功能,通过setup.py文件可以将python包按照指定的方案进行构建,构建出来的可执行文件是一个egg文件。最后将这个egg文件转移到python包的统一管理路径下,这样我们就可以在系统内任一位置的python文件中调用我们构建好的这个python库。
Python本身自带了一套工具distutils ,用于发布 Python 应用程序。但 distutils 没有提供定义其它依赖包的功能,setuptools 的真正优点并不在于实现distutils 所能实现的功能——尽管它的确增强了distutils的功能并简化了setup.py 脚本中的内容。setuptools 最大的优势是它在包管理能力方面的增强。它可以使用一种更加透明的方法来查找、下载并安装依赖包;并可以在一个包的多个版本中自由进行切换,这些版本都安装在同一个系统上;也可以声明对某个包的特定版本的需求;还可以只使用一个简单的命令就能更新到某个包的最新版本。 简单来说,Python setuptools可以看做是增强版的distutils,用来管理Python的各种包。
安装好之后,可以使用命令conda,可以使用一系列命令参数,conda --help 或 conda -h 、 conda --version 或 conda -V
在一个名为test_setup的路径下,作为我们最上层的项目根目录。然后在根目录下有需求配置文件requirements.txt,我们可以在这个文件中添加我们的python库所依赖的其他python库,如numpy、scipy等。而setup.py就是我们这里的安装文件,在后面的章节中会着重提到。最后是我们的项目的核心路径ts,里面包含了我们的核心代码。
类似于前一篇博文,http://www.cnblogs.com/zhongtang/p/7148082.html中描述的情况。
安装地址: https://pypi.python.org/pypi/setuptools#id9
setuptools是Python distutils增强版的集合,它可以帮助我们更简单的创建和分发Python包,尤其是拥有依赖关系的。用户在使用setuptools创建的包时,并不需要已安装setuptools,只要一个启动模块即可。
简介: Anaconda,中文大蟒蛇,是一个开源的Python发行版本,其包含了conda、Python等180多个科学包及其依赖项。
由于某些原因,没法在线安装setuptools,研究了一下官方提供的安装脚本,发现原来想要离线安装setuptools很简单。
因为项目的需求,要 lz4.0.10.1 的,因为本机已经有一个 1.1.0 版本的,所以必须先卸掉,然后我差点没疯了(手动微笑)
1. 【不能在cmd里install】之前一直在 cmd 里conda install psycopg2 ,pip install psycopg2,虽然提示安装成功,但是import时还是会报错提示包不存在。
如果有下面的异常信息,则先安装postgresql-devel* yum install postgresql-devel* 再安装 pip3 install psycopg2 异常: Collecting psycopg2 Using cached psycopg2-2.8.6.tar.gz (383 kB) ERROR: Command errored out with exit status 1: command: /usr/local/python3/bin/python3.8
分析:由于报错SSL证书验证失败,所以这次的访问应该是https协议.但是我们明明使用的是http,所以,猜测访问该网站后,被重定向到了https://www.baidu.com/
Starting >>> prius_line_following /usr/lib/python3/dist-packages/setuptools/dist.py:723: UserWarning: Usage of dash-separated 'script-dir' will not be supported in future versions. Please use the underscore name 'script_dir' instead warnings.warn( /usr/lib/python3/dist-packages/setuptools/dist.py:723: UserWarning: Usage of dash-separated 'install-scripts' will not be supported in future versions. Please use the underscore name 'install_scripts' instead warnings.warn( /usr/lib/python3/dist-packages/setuptools/dist.py:723: UserWarning: Usage of dash-separated 'script-dir' will not be supported in future versions. Please use the underscore name 'script_dir' instead warnings.warn( /usr/lib/python3/dist-packages/setuptools/dist.py:723: UserWarning: Usage of dash-separated 'install-scripts' will not be supported in future versions. Please use the underscore name 'install_scripts' instead warnings.warn( running egg_info writing ../build/prius_line_following/prius_line_following.egg-info/PKG-INFO writing dependency_links to ../build/prius_line_following/prius_line_following.egg-info/dependency_links.txt writing entry points to ../build/prius_line_following/prius_line_following.egg-info/entry_points.txt writing requirements to ../build/prius_line_following/prius_line_following.egg-info/requires.txt writing top-level names to ../build/prius_line_following/prius_line_following.egg-info/top_level.txt reading manifest file '../build/prius_line_following/prius_line_following.egg-info/SOURCES.txt' writing manifest file '../build/prius_line_following/prius_line_following.egg-info/SOURCES.txt' running build running build_py copying prius_line_following/line_following.py -> /home/zhangrelay/ros_ws/ROS2-Ultimate-Mobile-Robotics-Course-for-Beginners-OpenCV-main/prius_line_following/build/prius_line_following/build/lib/prius_line_following running install /usr/lib/python3/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and oth
列表推导式能非常简洁的构造一个新列表:只用一条简洁的表达式即可对得到的元素进行转换变形
当一个函数被调用的时候,就会创建一个局部作用域,在这个函数内的所有变量都存在于该局部作用域内(global的变量除外),该函数返回时,这个局部作用域被销毁,这个局部作用域内的局部变量随之丢失
1. 单文件模块:直接把文件拷贝到$python_dir/lib 这是类库目录(可直接将单文件或单包放在这里)
问题描述: 一片红海错误提示: Found existing installation: six 1.4.1 DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only pa
Traceback (most recent call last): File "/home/himalayas/fdsearch/fdsearch/bin/fdsearch", line 34, in <module> from fdsearch import wsgi File "/home/himalayas/fdsearch/fdsearch/wsgi.py", line 32, in <module> import fdsearch.domain File "/home/himalayas/fdsearch/fdsearch/domain/__init__.py", line 20, in <module> from notify_handler import NotifyHandler File "/home/himalayas/fdsearch/fdsearch/domain/notify_handler.py", line 23, in <module> from cjson import encode as json_encode File "build/bdist.linux-x86_64/egg/cjson.py", line 7, in <module> File "build/bdist.linux-x86_64/egg/cjson.py", line 4, in __bootstrap__ File "/home/himalayas/virtualenv/python2.7-fd/lib/python2.7/site-packages/pkg_resources.py", line 945, in resource_filename self, resource_name File "/home/himalayas/virtualenv/python2.7-fd/lib/python2.7/site-packages/pkg_resources.py", line 1633, in get_resource_filename self._extract_resource(manager, self._eager_to_zip(name)) File "/home/himalayas/virtualenv/python2.7-fd/lib/python2.7/site-packages/pkg_resources.py", line 1661, in _extract_resource self.egg_name, self._parts(zip_path) File "/home/himalayas/virtualenv/python2.7-fd/lib/python2.7/site-packages/pkg_resources.py", line 1025, in get_cache_path self.extraction_error() File "/home/himalayas/virtualenv/python2.7-fd/lib/python2.7/site-packages/pkg_resources.py", line 991, in extraction_error raise err pkg_resources.ExtractionError: Can't extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg cache: [Errno 13] Permission denied: '/root/.python-eggs' The Python egg cache directory is currently set to: /root/.python-eggs
OpenStack是目前我所知的最大最复杂的基于Python项目。整个OpenStack项目包含了数十个主要的子项目,每个子项目所用到的库也不尽相同。因此,对于Python初学者和未接触过OpenStack项目的人来说,入门的难度相当大。
/usr/lib/python3/dist-packages/setuptools/dist.py:723: UserWarning: Usage of dash-separated 'script-dir' will not be supported in future versions. Please use the underscore name 'script_dir' instead
supervisor的错误日志如下: Traceback (most recent call last): File "/home/himalayas/owengine/owprice/server.py", line 10, in <module> import action File "/home/himalayas/owengine/owprice/action/__init__.py", line 2, in <module> from owprice import owP
一个 Python 软件包中的 setup.py 文件包含这个 Python 包如何打包发布等重要信息。本文主要对这篇博客(https://amir.rachum.com/blog/2017/07/28/python-entry-points/)进行了翻译解读,以解释 Python setup.py 文件中 entry_point 用法。
出现这个问题是因为:虽然已经把Python升级到了2.7版本,但是pip仍然是原来的版本,仍在原来python的site-package里面
1.1 定义类 通常你需要在单独的文件中定义一个类 [root@hadron python]# vi Employee.py
网上很多做法是: 首先 find / -name mysql_config 在/usr/bin/下发现了这个文件 然后修改MySQL-python-1.2.5目录下的site.cfg文件 去掉mysql_config=XXX这行的注释,并改成mysql_config=/usr/bin/mysql_config(以mysql_config文件所在机器上的目录为准) 然后 python setup.py install 但是这样安装会出现: ExtractionError: Can't extract file
创建一个简单的 Python 库,调用myhellolib 一些需要打包的示例代码。该库接受一个字符串,然后以大写字母打印该字符串。 两行代码,但是项目结构很重要,所以先创建目录树:
文章作者:Tyan 博客:noahsnail.com | CSDN | 简书
编写setup.py文件,获取帮助:python setup.py --help-commands
自从上次发布开源库 aiowebsocket 之后,小奎因已经很久没有在公众号露面了。
wheel文件 Wheel和Egg都是python的打包格式,目的是支持不需要编译或制作的安装过程,实际上也是一种压缩文件,将.whl的后缀改为.zip即可可看到压缩包里面的内容。按照官网说法,wheels是发行版Python的新标准并且要取代.egg。 Egg格式是由setuptools在2004年引入,而Wheel格式是由PEP427在2012年定义。 Wheel现在被认为是Python的二进制包的标准格式。
-----------------------------------------
在本博另一篇文章“使用Buildout进行开发”中,有讲到使用Buildout来将Pyramid框架集成到Python环境中,并构建一个“helloworld”级别的Python Web应用。
1、# yum install Python-devel MySQL-devel zlib-devel openssl-devel
protobuf是Google提供的一个开源序列化框架,类似于XML,JSON这样的数据表示语言,其最大的特点是基于二进制,因此比传统的XML表示高效短小得多。开发者定义类似于结构体的message,通过protobuf的工具将定义好的格式传送给protobuf的接收工具,接收工具会自动产生类,需要传输的时候直接导入这个类,将关键字段填充,通过序列化函数,将其序列化,接收端将其反序列化,实现数据传输。protobuf支持c++,java,python。详细信息见参考文档。
最近在腾讯云上进行Python装包比较频繁,又碰上一些特殊情况,现就此进行简单总结。
Wheel和Egg都是python的打包格式,目的是支持不需要编译或制作的安装过程,实际上也是一种压缩文件,将.whl的后缀改为.zip即可可看到压缩包里面的内容。按照官网说法,wheels是发行版Python的新标准并且要取代.egg。 Egg格式是由setuptools在2004年引入,而Wheel格式是由PEP427在2012年定义。 Wheel现在被认为是Python的二进制包的标准格式。
详细错误如下 TypeError at / Object of type __proxy__ is not JSON serializable Request Method: GET Request URL: http://127.0.0.1:8000/ Django Version: 2.2.2 Exception Type: TypeError Exception Value: Object of type __proxy__ is not JSON serializable Except
想用redis-py-cluster连接redis cluter,查看文档发现只支持python2.7和3的版本,而系统自带的是2.6的版本,需要对系统python版本进行升级。
这篇文章主要介绍了Python的Paste库的使用,学习过程中主要参考官网文档以及自己的理解,整理成笔记以便后续自己查阅。 如果转载,请保留作者信息。 邮箱地址:jpzhang.ht@gmail.com Python Paste:http://pythonpaste.org/
一直以来都想着拯救我的 broken English,好准备接下来的六级考试。前段时间在 V2EX 看到一位大神分享了一份实用的英语学习指导 https://github.com/byoungd/English-level-up-tips-for-Chinese,遂被种草。同时我也认识到了自己单词量的匮乏,想通过背单词的方式把基础的词汇攒起来。恰好教程提供了一份「麦克米伦7000高频词」的 Anki 牌组,便打算从这里开始。
(venv) PS F:\Pycharm_Projects\Ruoyi-Energy> pip3 install django-export-xls
通常我们在python中定义一个函数的时候,需要给出明确的函数输入参量,比如对于一个数学函数
最近在学习python的django架构,学到数据库连接这部分,需要import MySQLdb这个模块,系统自带没有安装,于是乎用最简单的方法安装
关于python程序打包的介绍就不多说了,大部分的python基础书上都有介绍。这里就直接演练。
例如,很多时候Python开发人员都会去PyPI网站去查找自己想要使用的包,然后进行安装。PyPI ( Python Package Index)是获得第三方 Python 软件包以补充标准库的一个站点。
由于笔者自己经常忘记了如何查看Python的安装路径,又经常会用到Python的安装路径,因此记录一下,我们可以在命令行模式下输入:
领取专属 10元无门槛券
手把手带您无忧上云