草庐IT

basic_feature_names

全部标签

python - 导入错误 : No module named 'yaml'

我有一个脚本正在尝试执行python3env/common_config/add_imagepullsecret.py但是,我收到以下错误:[root@kevin]#python3env/common_config/add_imagepullsecret.pyTraceback(mostrecentcalllast):File"env/common_config/add_imagepullsecret.py",line4,inimportyamlImportError:Nomodulenamed'yaml'[root@kevin]#pip3installpyyamlRequiremen

python - 导入错误 : cannot import name 'transfer_markers' when testing with pytest

当我通过运行以下命令为我的python项目运行测试时:pythonsetup.pytest(or)pytestproject_name我收到以下错误:.../project_name/.eggs/pytest_asyncio-0.9.0-py3.6.egg/pytest_asyncio/plugin.py",line8,infrom_pytest.pythonimporttransfer_markersImportError:cannotimportname'transfer_markers' 最佳答案 当我在网上查找时,几乎没有任

Python 类变量名与 __name__

我试图了解分配给Python类对象的变量与该类对象的__name__属性之间的关系。例如:In[1]:classFoo(object):...:pass...:In[2]:Foo.__name__='Bar'In[3]:Foo.__name__Out[3]:'Bar'In[4]:FooOut[4]:__main__.BarIn[5]:Bar---------------------------------------------------------------------------NameErrorTraceback(mostrecentcalllast)in()---->1Ba

python - setattr(object, name, value) vs object.__setattr__(name, value)

我刚刚在阅读帖子HowcanIassignanewclassattributevia__dict__inpython?@brunodesthuilliers有一条评论说:Oneshouldn'tdirectlycallmagicmethods-theyarehereasimplementationofoperatorsorgenericfunctions.Inthiscase,theidiomaticsolutionistousesetattr(obj,name,value).setattr的情况似乎超出了他自己的评论范围:不是运算符,也不是通用函数的真正实现。有人可以解释评论吗?为什

python - 导入错误 : No module named pexpect

我正在使用Fabric并且想使用fexpect。我有以下Python脚本:fromilogue.fexpectimportexpect,expecting,run(...)definstall_postgresql(profile):print("!!!InstallingPostgreSQL...")print('->Doingpre-cleanup...')#RemovePostgreSQLifitexistsprompts=[]prompts+=expect('Doyouwanttocontinue[Y/n]?','Y')withsettings(warn_only=True):

python - 字段不存在 : ManyToManyField has no field named None

我在Django1.8.8中有两个模型:classCompany(models.Model):name=models.CharField(max_length=200)members=models.ManyToManyField(User)classFolder(models.Model):name=models.CharField(max_length=200)slug=models.SlugField(null=True,blank=True)company=models.ForeignKey(Company,null=True,blank=True)parent=models.F

python - pyodbc.错误 : ('IM002' , '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnect)' )

我正在尝试使用pyodbc连接到数据库并遇到以下错误,有人可以建议如何克服以下错误吗?使用以下命令安装pyodbcsudoapt-getinstallunixodbc-devpipinstallpyodbc代码:-#!/usr/bin/pythonimportpyodbcserver_name='odsdb.qualcomm.com'database_name='ODS'#cnx=pyodbc.connect("SERVER="+server_name+";DATABASE="+database_name)cnx=pyodbc.connect("DRIVER={SQLServer};S

python - PyQt4中自定义WM_NAME和WM_CLASS(如xprop所示)

如何自定义xprop所示的PyQt4程序的字符串WM_NAME和WM_CLASS?例如考虑:fromPyQt4importQtGui,QtCoreimportsysif__name__=='__main__':app=QtGui.QApplication(sys.argv)app.setStyle("plastique")listView=QtGui.QListView()listView.show()combobox=QtGui.QComboBox()combobox.show()sys.exit(app.exec_())如果我通过pythonxprop_test.py运行这个(文件

python - PyCharm (1.5.4) 和 Pandas 0.6.0 - ImportError : No module named data

我在MacOS10.6.4上使用PyCharm(1.5.4)作为我的pythonIDE。我正在修改一些代码来操纵股价数据。作为其中的一部分,我想使用Pandas0.6.0附带的DataReader函数从雅虎导入价格数据。代码如下:http://www.statalgo.com/2011/09/08/pandas-getting-financial-data-from-yahoo-fred-etc/frompandasimportols,DataFramefrompandas.stats.momentsimportrolling_stdfrompandas.io.dataimportDa

python - 使用 __getattr__(self, name) 访问实例的其他属性

在Python的documentation,onthe__getattr__function中它说:Notethatiftheattributeisfoundthroughthenormalmechanism,__getattr__()isnotcalled.(Thisisanintentionalasymmetrybetween__getattr__()and__setattr__().)Thisisdonebothforefficiencyreasonsandbecauseotherwise__getattr__()wouldhavenowaytoaccessotherattrib