草庐IT

import_module

全部标签

Python 导入错误 : cannot import name __version__

我正在尝试使用requests和requests_oauthlib,现在我只是在尝试他们在requests_oauthlib的文档中使用的非常简单的Twitter验证凭据示例,以确认我已经掌握了基础知识。我做了一个“pipinstallrequestsrequests_oauthlib”来获取模块。在终端窗口中,我可以“导入请求”没问题,但是当我尝试“导入requests_oauthlib”时,我得到了这个:>>>importrequests_oauthlibTraceback(mostrecentcalllast):File"",line1,inFile"/usr/lib/pytho

python - sys.modules 和 globals() 中的模块名称

如果我导入一个模块,模块名称会同时出现在sys.modules和globals()中。如果我再次删除它,它会从globals()中删除,但仍位于sys.modules中。为什么会这样?importmymodule'mymodule'inglobals()#True'mymodule'insys.modules#Truedelmymodule'mymodule'inglobals()#False'mymodule'insys.modules#StillTrue,why?我还发现了以下区别:frommypackageimportmymodule'mypackage'insys.module

python - Heroku ---> 安装 pip 远程 : AttributeError: module 'pip._vendor.requests' has no attribute 'Session'

一个Python3.6Django==11应用程序正在部署,并且代码会定期推送到昨天。现在我有错误:remote:AttributeError:module'pip._vendor.requests'hasnoattribute'Session'整个轨迹:Countingobjects:3,done.Deltacompressionusingupto4threads.Compressingobjects:100%(2/2),done.Writingobjects:100%(3/3),273bytes|0bytes/s,done.Total3(delta1),reused0(delta0

python - '从 X 导入 a' 与 'import X; X.a'

我见过一些Python程序员相当一致地使用以下风格(我们称之为风格1):importsome_module#Usesome_module.some_identifierinvariousplaces.对于这种风格的支持,你可以引用"explicitisbetterthanimplicit"格言。我见过其他程序员使用这种风格(风格2):fromsome_moduleimportsome_identifier#Usesome_identifierinvariousplaces.我在样式2中看到的主要好处是可维护性——尤其是ducktyping理想我可能想将some_module换成some

python - "from __future__ imports must occur at the beginning of the file": what defines the beginning of the file?

Python脚本'''a'''from__future__importprint_function运行良好(即什么都不做),但是'''a''''''b'''from__future__importprint_function原因:File"C:\test.py",line8from__future__importprint_functionSyntaxError:from__future__importsmustoccuratthebeginningofthefile为什么?https://docs.python.org/2/reference/simple_stmts.html#fu

python - Django 1.7 应用程序配置导入错误 : No module named appname. 应用程序

我正在尝试按照https://docs.djangoproject.com/en/dev/ref/applications/上的文档为我的一个名为“文章”的Django应用程序设置自定义应用程序配置。,但在执行./manage.pycheck(或任何其他管理命令,例如./manage.py运行服务器)这是项目树projectname├──apps│  ├──articles│  │  ├──admin.py│  │  ├──apps.py│  │  ├──__init__.py│  │  ├──migrations│  │  │  ├──0001_initial.py│  │  │  

python - Py2Exe "Missing Modules"

我正在尝试使用Py2Exe将我的python项目转换为exe。值得注意的是,cx_freeze提示同样的三个“缺失模块”,以及其他几十个模块。问题是,没有人告诉我们如何解决这个问题。我正在MSWindowsXP32位(VirtualBox)上构建。C:\DocumentsandSettings\Jason\Desktop\redstring2>pythonsetup.pypy2exerunningpy2exerunningbuild_pycreatingbuildcreatingbuild\libcopyingredstring.py->build\lib3missingModules

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

我正在尝试学习pandas,但无法将其导入我的代码。我查看了该网站上的其他答案,但没有一个有效。我刚刚安装了anaconda并通过conda安装了所有东西。这是我尝试运行的示例脚本。importpandasaspdwriter=pd.ExcelWriter('farm_data.xlsx',engine='xlsxwriter')df.to_excel(writer,sheet_name='Sheet1')workbook=writer.bookworksheet=writer.sheets['Sheet1']chart=workbook.add_chart({'type':'colu

python - 使用 cx_Freeze 和 tkinter 时,我得到 : "DLL load failed: The specified module could not be found." (Python 3. 5.3)

当使用cx_Freeze和Tkinter时,我收到消息:File"C:\Users\VergilTheHuragok\AppData\Local\Programs\Python\Python35-32\lib\tkinter\__init__.py",line35,inimport_tkinter#IfthisfailsyourPythonmaynotbeconfiguredforTkImportError:DLLloadfailed:Thespecifiedmodulecouldnotbefound.一些注意事项:我想使用Python3+(目前使用3.5.3,32位)。并不真正关心特