草庐IT

total_commands_processed

全部标签

Python anaconda conda 问题 : updating anaconda package impossible because processes are running

我在使用conda更新anaconda的包时遇到问题。当我进行condaupdate--all时,有一个问题对我说:Error:Unabletoremovefilesforpackage:cryptographyPleasecloseallprocessesrunningcodefromcryptographyandtryagain.但是,没有进程在运行,我只是打开了cmd窗口。例如,当我想要更新dateutile时,情况相同。就像conda使用了一些包然后我无法更新它们一样?有人知道关闭或删除这些软件包以重新安装它们的方法吗?信息:C:\Anaconda3\Scripts>conda

Python、Scrapy、管道 : function "process_item" not getting called

我有一个非常简单的代码,如下所示。抓取没问题,我可以看到所有生成正确数据的print语句。在Pipeline中,初始化工作正常。但是,process_item函数不会被调用,因为函数开头的print语句永远不会执行。蜘蛛:comosham.pyimportscrapyfromscrapy.spiderimportSpiderfromscrapy.selectorimportSelectorfromscrapy.httpimportRequestfromactivityadvisor.itemsimportComoShamLocationfromactivityadvisor.items

python - pip 无法安装任何东西,错误 : invalid command 'egg_info'

除了MacOSX自带的Python版本之外,我最近还从他们的网站下载了python。这是我开始在使用pip安装软件包时遇到问题。sudopipinstall-vvvpygoogle将输出如下:Thedirectory'/Users/robot/Library/Caches/pip/http'oritsparentdirectoryisnotownedbythecurrentuserandthecachehasbeendisabled.Pleasecheckthepermissionsandownerofthatdirectory.Ifexecutingpipwithsudo,youma

python - 撤消 "Install Certificates.command"

在Mac上的Python3.6+中,各种与SSL相关的操作将失败(通常带有神秘的SSL:CERTIFICATE_VERIFY_FAILED错误),直到您运行/Applications/Python\3.6/Install\Certificates.command安装根证书。遇到这样的错误后,我用谷歌搜索,最终发现了这个解决方案(在例如https://bugs.python.org/issue29065#msg283984中注明),并成功了。但现在我想调整我的代码以捕获我之前看到的错误并显示一条有用的错误消息,向用户解释他们需要运行/Applications/Python\3.6/Ins

python 素数处理 : processing pool is slower?

所以最近几天我一直在摆弄python的多处理库,我真的很喜欢处理池。它很容易实现,我可以想象出很多用途。我已经完成了几个我以前听说过的项目来熟悉它,最近完成了一个暴力破解刽子手游戏的程序。任何人,我正在做一个执行时间比较,对单线程和处理池中100万到200万之间的所有素数求和。现在,对于hangmancruncher来说,将游戏放在处理池中可以将执行时间提高大约8倍(i7具有8个内核),但是当磨掉这些素数时,它实际上增加处理时间几乎是4倍。谁能告诉我这是为什么?这是供有兴趣查看或测试它的任何人使用的代码:#!/user/bin/python.exeimportmathfrommulti

python - 将 management.call_command() 标准输出重定向到文件

我一直在尝试使用这段代码重定向自定义django命令的标准输出:fromdjango.core.management.baseimportBaseCommandfromdjango.coreimportmanagementclassCommand(BaseCommand):defhandle(self,*args,**options):f=open('/tmp/output','r+')management.call_command('basequery','list','log',stdout=f)f.close()但是,当我从manage.py调用它时,标准输出出现在控制台上,并且

python - Argparse 子解析器 : hide metavar in command listing

我在我的程序中使用Pythonargparse模块作为命令行子命令。我的代码基本上是这样的:importargparseparser=argparse.ArgumentParser()subparsers=parser.add_subparsers(title="subcommands",metavar="")subparser=subparsers.add_parser("this",help="dothis")subparser=subparsers.add_parser("that",help="dothat")parser.parse_args()运行“pythontest.p

python - 无法安装 Orange : "error: command ' clang' failed with exit status 1"

我正在尝试安装Orange在我的MacOSX10.7.3(Lion)上,我在使用pip或从源代码构建时不断收到错误消息。首先,我收到一条错误消息:error:command'gcc-4.0'failedwithexitstatus1我有Xcode4,它与gcc4.2.1捆绑在一起。所以我安装了64-bit/32-bitPython2.7.3,它内置了gcc4.2。我还尝试使用以下方法覆盖编译器选择:exportCC=gcc-4.2但这产生了不同的错误:gcc-4.2notfound,usingclanginstead...error:command'clang'failedwithex

python - 找不到 Pandas Series.dt.total_seconds()

我需要一个以秒为单位的日期时间列,到处都是(includingthedocs)说我应该使用Series.dt.total_seconds()但它找不到函数。我假设我有一些错误的版本,但我没有...pipfreeze|greppandaspandas==0.20.3python--versionPython3.5.3这一切都在一个virtualenv中,它已经运行了很长时间而没有错误,其他Series.dt函数也可以运行。这是代码:frompandasimportSeriesfromdatetimeimportdatetimes=Series([datetime.now()for_inr

python - Nltk 斯坦福 pos 标记器错误 : Java command failed

我正在尝试使用nltk.tag.stanfordmodule用于标记句子(首先像wiki的示例),但我不断收到以下错误:Traceback(mostrecentcalllast):File"test.py",line28,inprintst.tag(word_tokenize('Whatistheairspeedofanunladenswallow?'))File"/usr/local/lib/python2.7/dist-packages/nltk/tag/stanford.py",line59,intagreturnself.tag_sents([tokens])[0]File"/