草庐IT

Bird_Name

全部标签

python - 导入错误 : cannot import name np_utils

我正在尝试运行以下example来自keras但我收到此错误:ImportErrorTraceback(mostrecentcalllast)in()8importnumpyasnp9importmatplotlib.pyplotasplt--->10fromkeras.modelsimportSequential11fromkeras.layersimportDense,LSTM12/usr/local/lib/python2.7/dist-packages/keras/__init__.pyin()1from__future__importabsolute_import2---->

python - related_name 参数在 Django 模型中没有按预期工作?

我最近在我的Django模型中遇到了ForeignKey冲突。我需要有两个外键(owner、assigned_to)最终指向同一个模型(一个用户)。据我了解,我需要一个related_name参数来解决该问题。所以我这样做了:assigned_to=models.ForeignKey(TaskUser,blank=True,null=True,related_name='user_assignment')和owner=models.ForeignKey(TaskUser,related_name="user_ownership"但我仍然收到错误消息:tasks.task:Accesso

python - 是否有与 Python 的 `if __name__ == ' __main_ _'` 等效的 Perl?

有没有办法确定当前文件是否是在Perl源代码中执行的文件?在Python中,我们使用以下结构来做到这一点:if__name__=='__main__':#Thisfileisbeingexecuted.raiseNotImplementedError我可以使用FindBin和__FILE__一起破解一些东西,但我希望有一种规范的方式来做到这一点。谢谢! 最佳答案 unless(caller){print"Thisisthescriptbeingexecuted\n";}见caller.它在主脚本中返回undef。请注意,这在子例程中

python - 安装 iPython : "ImportError cannot import name path"?

我正在尝试安装IPython。我已经运行pipinstallipython[notebook]没有任何错误,但现在我明白了:$ipythonnotebookTraceback(mostrecentcalllast):File"/Users/me/.virtualenvs/.venv/bin/ipython",line7,infromIPythonimportstart_ipythonFile"/Users/me/.virtualenvs/.venv/lib/python2.7/site-packages/IPython/__init__.py",line48,infrom.termin

python - ubuntu 导入错误 : cannot import name MAXREPEAT

升级到13.04完全搞砸了我的系统。我在运行时遇到了这个问题./manage.pyrunserverTraceback(mostrecentcalllast):File"./manage.py",line8,infromdjango.core.managementimportexecute_from_command_lineFile"/home/rats/rats/local/lib/python2.7/site-packages/django/core/management/__init__.py",line4,infromoptparseimportOptionParser,NO_

python - 名称错误 : name 'datetime' is not defined

我正在自学Python,只是在“探索”。Google说datetime是一个全局变量,但是当我尝试在终端中查找今天的日期时,我在问题标题中收到NameError?mynames-MacBook:pythonhardmyname$pythonEnthoughtCanopyPython2.7.3|64-bit|(default,Aug82013,05:37:06)[GCC4.2.1(AppleInc.build5666)(dot3)]ondarwinType"help","copyright","credits"or"license"formoreinformation.>>>date=d

python - 错误信息 "python-pylint ' C0103 :Invalid constant name"

我对这张照片中的错误感到困惑:我不知道如何解决它们。我的程序是Python-Flask网络框架。当我使用VisualStudioCode调试我的程序时,Pylint会显示这些错误。我知道这个问题无关紧要,但它让我很恼火。我该如何解决?#-*-coding:utf-8-*-importsysfromflaskimportFlaskfromflask_bootstrapimportBootstrapfromflask_momentimportMoment#fromflask_wtfimportForm#fromwtformsimportStringField,SubmitField#fro

Python名称错误: name is not defined

我有一个python脚本,但收到以下错误:Traceback(mostrecentcalllast):File"C:\Users\Tim\Desktop\pop-erp\test.py",line1,ins=Something()NameError:name'Something'isnotdefined这是导致问题的代码:s=Something()s.out()classSomething:defout():print("itworks")这是在Windows7x86-64下使用Python3.3.0运行的。为什么找不到Something类? 最佳答案

python - 从同名脚本导入已安装的包会引发 "AttributeError: module has no attribute"或 "ImportError: cannot import name"

我有一个名为requests.py的脚本,用于导入requests包。该脚本要么无法访问包中的属性,要么无法导入它们。为什么这不起作用,我该如何解决?以下代码引发AttributeError。importrequestsres=requests.get('http://www.google.ca')print(res)Traceback(mostrecentcalllast):File"/Users/me/dev/rough/requests.py",line1,inimportrequestsFile"/Users/me/dev/rough/requests.py",line3,in

python NameError : name 'file' is not defined

我对python了解不多。我想开始这个项目,安装说明说:pipinstall-rrequirements-dev.txt足够简单。问题是我得到了这个:Downloading/unpackinggunicorn==0.13.4(from-rrequirements.txt(line7))Runningsetup.pyegg_infoforpackagegunicornTraceback(mostrecentcalllast):File"",line16,inFile"/tmp/pip-build-root/gunicorn/setup.py",line18,inlong_descript