Py2.7 no module named tkinter

一个简单的例子

#! /usr/bin/env python
#coding=utf-8
from tkinter import *
Label(text="Spam").pack()
mainloop()

 

运行起来却报: no module named tkinter,查了一下,却发现是一个很有趣的原因:

Tkinter (capitalized) refers to versions <3.0.

tkinter (all lowecase) refers to versions ≥3.0

ImportError: No module named '_pywrap_tensorflow_internal'

11-05

tensorflow==1.5.0 安装成功;继续安装gpu版本,按系统提示再安装 CUDA-9.0, cuDNN-7.0: cuda_9.0.176_win10_network以及patch1-4 / cudnn-9.0-windows10-x64-v7.3.1.20. 运行‘import tensorflow as tf’后报错: ImportError: No module named '_pywrap_tensorflow_internal'rnrn谢谢帮助rnrn ---------------------------------------------------------------------------rnImportError Traceback (most recent call last)rnC:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()rn 17 try:rn---> 18 return importlib.import_module(mname)rn 19 except ImportError:rnrnC:\Program Files\Anaconda3\lib\importlib\__init__.py in import_module(name, package)rn 125 level += 1rn--> 126 return _bootstrap._gcd_import(name[level:], package, level)rn 127 rnrnC:\Program Files\Anaconda3\lib\importlib\_bootstrap.py in _gcd_import(name, package, level)rnrnC:\Program Files\Anaconda3\lib\importlib\_bootstrap.py in _find_and_load(name, import_)rnrnC:\Program Files\Anaconda3\lib\importlib\_bootstrap.py in _find_and_load_unlocked(name, import_)rnrnC:\Program Files\Anaconda3\lib\importlib\_bootstrap.py in _load_unlocked(spec)rnrnC:\Program Files\Anaconda3\lib\importlib\_bootstrap.py in module_from_spec(spec)rnrnC:\Program Files\Anaconda3\lib\importlib\_bootstrap_external.py in create_module(self, spec)rnrnC:\Program Files\Anaconda3\lib\importlib\_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)rnrnImportError: DLL load failed: 找不到指定的程序。rnrnDuring handling of the above exception, another exception occurred:rnrnImportError Traceback (most recent call last)rnC:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in ()rn 57 rn---> 58 from tensorflow.python.pywrap_tensorflow_internal import *rn 59 from tensorflow.python.pywrap_tensorflow_internal import __version__rnrnC:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in ()rn 20 return importlib.import_module('_pywrap_tensorflow_internal')rn---> 21 _pywrap_tensorflow_internal = swig_import_helper()rn 22 del swig_import_helperrnrnC:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()rn 19 except ImportError:rn---> 20 return importlib.import_module('_pywrap_tensorflow_internal')rn 21 _pywrap_tensorflow_internal = swig_import_helper()rnrnC:\Program Files\Anaconda3\lib\importlib\__init__.py in import_module(name, package)rn 125 level += 1rn--> 126 return _bootstrap._gcd_import(name[level:], package, level)rn 127 rnrnImportError: No module named '_pywrap_tensorflow_internal'rnrnDuring handling of the above exception, another exception occurred:rnrnImportError Traceback (most recent call last)rn in ()rn----> 1 import tensorflow as tfrnrnC:\Program Files\Anaconda3\lib\site-packages\tensorflow\__init__.py in ()rn 22 rn 23 # pylint: disable=wildcard-importrn---> 24 from tensorflow.python import *rn 25 # pylint: enable=wildcard-importrn 26 rnrnC:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\__init__.py in ()rn 47 import numpy as nprn 48 rn---> 49 from tensorflow.python import pywrap_tensorflowrn 50 rn 51 # Protocol buffersrnrnC:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in ()rn 72 for some common reasons and solutions. Include the entire stack tracern 73 above this error message when asking for help.""" % traceback.format_exc()rn---> 74 raise ImportError(msg)rn 75 rn 76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-longrnrnImportError: Traceback (most recent call last):rn File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helperrn return importlib.import_module(mname)rn File "C:\Program Files\Anaconda3\lib\importlib\__init__.py", line 126, in import_modulern return _bootstrap._gcd_import(name[level:], package, level)rn File "", line 986, in _gcd_importrn File "", line 969, in _find_and_loadrn File "", line 958, in _find_and_load_unlockedrn File "", line 666, in _load_unlockedrn File "", line 577, in module_from_specrn File "", line 906, in create_modulern File "", line 222, in _call_with_frames_removedrnImportError: DLL load failed: 找不到指定的程序。rnrnDuring handling of the above exception, another exception occurred:rnrnTraceback (most recent call last):rn File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in rn from tensorflow.python.pywrap_tensorflow_internal import *rn File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in rn _pywrap_tensorflow_internal = swig_import_helper()rn File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helperrn return importlib.import_module('_pywrap_tensorflow_internal')rn File "C:\Program Files\Anaconda3\lib\importlib\__init__.py", line 126, in import_modulern return _bootstrap._gcd_import(name[level:], package, level)rnImportError: No module named '_pywrap_tensorflow_internal'rnrnrnFailed to load the native TensorFlow runtime.rnrnSee https://www.tensorflow.org/install/install_sources#common_installation_problemsrnrnfor some common reasons and solutions. Include the entire stack tracernabove this error message when asking for help. 问答

python:no module named MySQLdb

03-05

想用django开发网站。使用的是python2.7,操作系统win10.已经安装好了Anaconda和mysql。现在想进行连接数据库,已经在网站下载并安装了多个版本的python-mysql驱动(1.2.3版本等),然后再import MySQLdb,还是提示no module named MySQLdbrnrnrn在C:\Anaconda2\Lib\site-packages也已经有了C:\Anaconda2\Lib\site-packages\MySQL_python-1.2.3-py2.7.egg-info和C:\Anaconda2\Lib\site-packages\MySQLdb。rnrn为什么就是不能成功呢?rnrndjango在启动服务的时候,错误为:rnC:\Anaconda2\Django-1.9.4\django\bin\hello>python manage.py runsever 0.0.0.0:8080rnTraceback (most recent call last):rn File "manage.py", line 10, in rn execute_from_command_line(sys.argv)rn File "F:\Anaconda\lib\site-packages\django-1.9.4-py2.7.egg\django\core\management\__init__.py", line 353, in execute_from_command_linern utility.execute()rn File "F:\Anaconda\lib\site-packages\django-1.9.4-py2.7.egg\django\core\management\__init__.py", line 327, in executern django.setup()rn File "F:\Anaconda\lib\site-packages\django-1.9.4-py2.7.egg\django\__init__.py", line 18, in setuprn apps.populate(settings.INSTALLED_APPS)rn File "F:\Anaconda\lib\site-packages\django-1.9.4-py2.7.egg\django\apps\registry.py", line 108, in populatern app_config.import_models(all_models)rn File "F:\Anaconda\lib\site-packages\django-1.9.4-py2.7.egg\django\apps\config.py", line 202, in import_modelsrn self.models_module = import_module(models_module_name)rn File "F:\Anaconda\lib\importlib\__init__.py", line 37, in import_modulern __import__(name)rn File "F:\Anaconda\lib\site-packages\django-1.9.4-py2.7.egg\django\contrib\auth\models.py", line 4, in rn from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManagerrn File "F:\Anaconda\lib\site-packages\django-1.9.4-py2.7.egg\django\contrib\auth\base_user.py", line 49, in rn class AbstractBaseUser(models.Model):rn File "F:\Anaconda\lib\site-packages\django-1.9.4-py2.7.egg\django\db\models\base.py", line 108, in __new__rn new_class.add_to_class('_meta', Options(meta, app_label))rn File "F:\Anaconda\lib\site-packages\django-1.9.4-py2.7.egg\django\db\models\base.py", line 299, in add_to_classrn value.contribute_to_class(cls, name)rn File "F:\Anaconda\lib\site-packages\django-1.9.4-py2.7.egg\django\db\models\options.py", line 263, in contribute_to_classrn self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())rn File "F:\Anaconda\lib\site-packages\django-1.9.4-py2.7.egg\django\db\__init__.py", line 36, in __getattr__rn return getattr(connections[DEFAULT_DB_ALIAS], item)rn File "F:\Anaconda\lib\site-packages\django-1.9.4-py2.7.egg\django\db\utils.py", line 212, in __getitem__rn backend = load_backend(db['ENGINE'])rn File "F:\Anaconda\lib\site-packages\django-1.9.4-py2.7.egg\django\db\utils.py", line 116, in load_backendrn return import_module('%s.base' % backend_name)rn File "F:\Anaconda\lib\importlib\__init__.py", line 37, in import_modulern __import__(name)rn File "F:\Anaconda\lib\site-packages\django-1.9.4-py2.7.egg\django\db\backends\mysql\base.py", line 28, in rn raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)rndjango.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb 论坛

关于....No module named urls

12-05

1,向你的模型添加admin metadatarn并不是所有的模型都可以或者应该被admin用户编辑,所以你需要标记那些需要管理界面的模型rn上一章的Book模型添加一个管理界面的方法就是:rnJava代码 复制代码rnrn 1. class Book(models.Model): rn 2. title = models.CharField(maxlength=100) rn 3. authors = models.ManyToManyField(Author) rn 4. publisher = models.ForeignKey(Publisher) rn 5. publication_date = models.DateField() rn 6. rn 7. class Admin: rn 8. pass rnrnclass Book(models.Model):rn title = models.CharField(maxlength=100)rn authors = models.ManyToManyField(Author)rn publisher = models.ForeignKey(Publisher)rn publication_date = models.DateField()rnrn class Admin:rn passrnrnrnAdmin声明标记这个类拥有一个管理界面,在Admin之下你可以配置许多选项rn目前我们采用默认值,所以我们使用pass来表示Admin类是空的rn如果你正在按这个例子写自己的代码,现在给Publisher和Author类添加Admin声明是个好主意rn2,安装admin模型,简单的把"django.contrib.admin"添加到你的INSTALLED_APPS设置里rn然后运行python manage.py syncdb来安装admin使用的额外的表rn注意,在你第一次运行syncdb时,你很可能被问起是否创建一个superuserrn如果那时你没有创建superuser,你需要运行djang/contrib/auth/bin/create_superuser.pyrn来创建一个admin用户,否则你就不能登录到管理界面里去rn3,把URL模式添加到urls.py,如果仍在使用startproject创建的工程,admin的URL模式可能rn已经在那儿了,但是被注释掉了,你的URL模式应该像这样:rnJava代码 复制代码rnrn 1. from django.conf.urls.defaults import * rn 2. rn 3. urlpatterns = patterns('', rn 4. (r'^admin/', include('django.contrib.admin.urls')), rn 5. ) rnrnfrom django.conf.urls.defaults import *rnrnurlpatterns = patterns('',rn (r'^admin/', include('django.contrib.admin.urls')),rn)rnrnrn就这样,现在运行python manage.py runserver来启动服务器,你将看到如下信息:rnValidating models...rn0 errors found.rnrnDjango version 0.96-pre, using settings 'mysite.settings'rnDevelopment server is running at http://127.0.0.1:8000/rnQuit the server with CONTROL-C. rnrn但当我进入http://127.0.0.1:8000/admin/时。。。。就会出现rnrnImportError at /admin/rnrnNo module named urlsrnrn错误。。。怎么解决呢。。。请各位高手帮帮忙吧!rnrn我看到在我的django.contrib.admin 目录下没有urls.py文件啊! 论坛

importError No module named multiarry

05-28

在terminal输入python后,执行命令报错:rn [code=python]rn import numpyrn import picklern import numpy.core.multiarrayrn data = pickle.load(open('Workspace/Ch5_Py_Mrjob_PegasosSVM/svmDat27','rb'))[/code]rn报错:rnTraceback (most recent call last):rn File "", line 1, in rn File "/home/hduser/anaconda2/lib/python2.7/pickle.py", line 1384, in loadrn return Unpickler(file).load()rn File "/home/hduser/anaconda2/lib/python2.7/pickle.py", line 864, in loadrn dispatch[key](self)rn File "/home/hduser/anaconda2/lib/python2.7/pickle.py", line 1096, in load_globalrn klass = self.find_class(module, name)rn File "/home/hduser/anaconda2/lib/python2.7/pickle.py", line 1130, in find_classrn __import__(module)rnImportError: No module named multiarrayrn rn [code=python]data = pickle.load(open('Workspace/Ch5_Py_Mrjob_PegasosSVM/svmDat27','r'))[/code]rn报错:rnTraceback (most recent call last):rn File "", line 1, in rn File "/home/hduser/anaconda2/lib/python2.7/pickle.py", line 1384, in loadrn return Unpickler(file).load()rn File "/home/hduser/anaconda2/lib/python2.7/pickle.py", line 864, in loadrn dispatch[key](self)rn File "/home/hduser/anaconda2/lib/python2.7/pickle.py", line 1096, in load_globalrn klass = self.find_class(module, name)rn File "/home/hduser/anaconda2/lib/python2.7/pickle.py", line 1130, in find_classrn __import__(module)rnImportError: No module named multiarrayrn rn [code=python] data = pickle.load(open('Workspace/Ch5_Py_Mrjob_PegasosSVM/svmDat27'))[/code]rn继续报错:rnTraceback (most recent call last):rn File "", line 1, in rn File "/home/hduser/anaconda2/lib/python2.7/pickle.py", line 1384, in loadrn return Unpickler(file).load()rn File "/home/hduser/anaconda2/lib/python2.7/pickle.py", line 864, in loadrn dispatch[key](self)rn File "/home/hduser/anaconda2/lib/python2.7/pickle.py", line 1096, in load_globalrn klass = self.find_class(module, name)rn File "/home/hduser/anaconda2/lib/python2.7/pickle.py", line 1130, in find_classrn __import__(module)rnImportError: No module named multiarrayrnrnrn在终端输入,感觉不存在编码问题;换了个机子用本机自带的python27运行报同样的错误!rnrn[color=#0000FF][b][size=16px]有没有哪位大神趟过相同的坑,恳请指教!至今没有解决问题~~~[/size][/b][/color]rnrn 论坛

没有更多推荐了,返回首页