草庐IT

global-require

全部标签

python - 通过 pip : this package requires Python 3. 3 或更高版本为 python 2.7 安装 py2exe

>>>python-c"importsys;printsys.version"2.7.6(default,Nov102013,19:24:18)[MSCv.150032bit(Intel)]>>>pip--versionpip1.5.5fromC:\Python27\lib\site-packages(python2.7)>>>pipinstallpy2exeRuntimeError:ThispackagerequiresPython3.3orlater虽然是官方的py2exedownloadpage说他们有我需要的东西:那么如何通过pip安装py2exe?

python - 类型错误 : a bytes-like object is required, 不是 'str'

以下是尝试使用套接字修改用户提供的输入的代码:fromsocketimport*serverName='127.0.0.1'serverPort=12000clientSocket=socket(AF_INET,SOCK_DGRAM)message=input('Inputlowercasesentence:')clientSocket.sendto(message,(serverName,serverPort))modifiedMessage,serverAddress=clientSocket.recvfrom(2048)print(modifiedMessage)clientSo

python - 名称错误 : global name 'execfile' is not defined trying to run an app on Google App Engine Launcher

我在Windows中收到此错误,我有3.2和2.7版本的python。我该如何解决这个问题? 最佳答案 您只需要转到编辑/首选项并指定正确版本的python路径 关于python-名称错误:globalname'execfile'isnotdefinedtryingtorunanapponGoogleAppEngineLauncher,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions

python - 将 conda environment.yml 与 pip requirements.txt 相结合

我使用conda环境,也需要一些pip包,例如来自~gohlke的预编译轮子.目前我有两个文件:environment.ymlforcondawith:#run:condaenvcreate--fileenvironment.ymlname:test-envdependencies:-python>=3.5-anaconda和requirements.txt为pip,激活上述conda环境后即可使用:#run:pipinstall-irequirements.txtdocxgooeyhttp://www.lfd.uci.edu/~gohlke/pythonlibs/bofhrmxk/o

python - requirements.txt 与 setup.py

我开始使用Python。我已将requirements.txt和setup.py添加到我的项目中。但是,我仍然对这两个文件的目的感到困惑。我读过setup.py是为可再发行的东西而设计的,而requirements.txt是为不可再发行的东西而设计的。但我不确定这是否准确。这两个文件的真正用途是什么? 最佳答案 requirements.txt:这可以帮助您设置开发环境。pip之类的程序可用于一举安装文件中列出的所有软件包。之后,您可以开始开发您的python脚本。如果您计划让其他人参与开发或使用虚拟环境,则特别有用。这就是你使用它

Python 安装工具 : How can I list a private repository under install_requires?

我正在创建一个setup.py依赖于私有(private)GitHub存储库的项目的文件。文件的相关部分如下所示:fromsetuptoolsimportsetupsetup(name='my_project',...,install_requires=['public_package','other_public_package','private_repo_1','private_repo_2',],dependency_links=['https://github.com/my_account/private_repo_1/master/tarball/','https://gi

python - 仅使用 "conda install --yes --file requirements.txt"安装可用的软件包而不会出错

通过以下命令使用Conda在requirements.txt中安装包时condainstall--yes--filerequirements.txt如果requirements.txt中的包不可用,则会引发“无包错误”,如下所示:UsingAnacondaCloudapisitehttps://api.anaconda.orgFetchingpackagemetadata:....Error:Nopackagesfoundincurrentlinux-64channelsmatching:nimfa==1.2.3Youcansearchforthispackageonanaconda.

python - Python 中 globals() 的原因?

Python中有globals()函数的原因是什么?它只返回全局变量的字典,这些变量已经是全局的,所以它们可以在任何地方使用……我只是出于好奇,试图学习python。defF():globalxx=1defG():print(globals()["x"])#willreturnvalueofglobal'x',whichis1defH():print(x)#willalsoreturnvalueofglobal'x',which,also,is1F()G()H()我真的看不出这里的重点?只有当我有本地和全局变量时,我才需要它,它们的名称相同defF():globalxx=1defG()

python - requirements.txt 取决于 python 版本

我正在尝试使用六个将python2包移植到python3(不是我自己的),以便它与两者兼容。但是,requirements.txt中列出的软件包之一现在包含在python3标准库中,并且pypi版本在python3中不起作用,所以我想有条件地排除它。在setup.py中执行此操作很简单,我可以执行以下操作:ifsys.version_info[0]==2:requirements+=py2_requirementselse:requirements+=py3_requirements但我希望requirements.txt也能反射(reflect)正确的列表。我在pip文档中找不到任何

global-variables - 在 config.py 中提供全局配置变量的大多数 Pythonic 方式?

关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题吗?更新问题,以便editingthispost提供事实和引用来回答它.关闭2年前。社区审核了是否重新打开这个问题10个月前并关闭:原始关闭原因未解决Improvethisquestion在将简单的东西过度复杂化的无尽探索中,我正在研究最“Pythonic”的方法,以在Pythonegg包中的典型“config.py”中提供全局配置变量。传统方式(aah,goodol'#define!)如下:MYSQL_PORT=3306MYSQL_DATABASE='mydb'MYSQL_DATABASE_TABLES=[