关于在centos下安装python3.7.0以上版本时报错ModuleNotFoundError: No module named '_ctypes'

参考文章:https://blog.csdn.net/qq_36416904/article/details/79316972

3.7版本需要一个新的包libffi-devel,安装此包之后再次进行编译安装即可。

$ yum -y install libffi-devel

$ make && make install

ps: && 表示前面的命令可以执行成功再执行后面的命令

展开阅读全文

python ,显示ModuleNotFoundError: No module named 'exception'

05-02

显示错误,使用的是python3.6rn如果不能够使用这个模块,可以换成什么呢? 还是python3没有整个模块呢rnrn[code=python]Traceback (most recent call last):rn File "C:\Users\IBM\Desktop\商品信息.py", line 4, in rn from exception import ValueErrorrnModuleNotFoundError: No module named 'exception'[/code]rnrn[code=python]from lxml import html rnimport csv,os,jsonrnimport requestsrnfrom exception import ValueErrorrnfrom time import sleeprnrndef AmzonParser(url):rn headers = 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36'rn page = requests.get(url,headers=headers)rn while True:rn sleep(3)rn try:rn doc = html.fromstring(page.content)rn XPATH_NAME = '//h1[@id="title"]//text()'rn XPATH_SALE_PRICE = '//span[contains(@id,"ourprice") or contains(@id,"saleprice")]/text()'rn XPATH_ORIGINAL_PRICE = '//td[contains(text(),"List Price") or contains(text(),"M.R.P") or contains(text(),"Price")]/following-sibling::td/text()'rn XPATH_CATEGORY = '//a[@class="a-link-normal a-color-tertiary"]//text()'rn XPATH_AVAILABILITY = '//div[@id="availability"]//text()'rnrn RAW_NAME = doc.xpath(XPATH_NAME)rn RAW_SALE_PRICE = doc.xpath(XPATH_SALE_PRICE)rn RAW_CATEGORY = doc.xpath(XPATH_CATEGORY)rn RAW_ORIGINAL_PRICE = doc.xpath(XPATH_ORIGINAL_PRICE)rn RAw_AVAILABILITY = doc.xpath(XPATH_AVAILABILITY)rnrn NAME = ' '.join(''.join(RAW_NAME).split()) if RAW_NAME else Nonern SALE_PRICE = ' '.join(''.join(RAW_SALE_PRICE).split()).strip() if RAW_SALE_PRICE else Nonern CATEGORY = ' > '.join([i.strip() for i in RAW_CATEGORY]) if RAW_CATEGORY else Nonern ORIGINAL_PRICE = ''.join(RAW_ORIGINAL_PRICE).strip() if RAW_ORIGINAL_PRICE else Nonern AVAILABILITY = ''.join(RAw_AVAILABILITY).strip() if RAw_AVAILABILITY else Nonernrn if not ORIGINAL_PRICE:rn ORIGINAL_PRICE = SALE_PRICErnrn if page.status_code!=200:rn raise ValueError('captha')rn data = rn 'NAME':NAME,rn 'SALE_PRICE':SALE_PRICE,rn 'CATEGORY':CATEGORY,rn 'ORIGINAL_PRICE':ORIGINAL_PRICE,rn 'AVAILABILITY':AVAILABILITY,rn 'URL':url,rn rnrn return datarn except Exception as e:rn print (e) rndef ReadAsin():rn # AsinList = csv.DictReader(open(os.path.join(os.path.dirname(__file__),"Asinfeed.csv")))rn AsinList = ['B0046UR4F4',rn 'B00JGTVU5A',rn 'B00GJYCIVK',rn 'B00EPGK7CQ',rn 'B00EPGKA4G',rn 'B00YW5DLB4',rn 'B00KGD0628',rn 'B00O9A48N2',rn 'B00O9A4MEW',rn 'B00UZKG8QU',]rn extracted_data = []rn for i in AsinList:rn url = "http://www.amazon.com/dp/"+irn print ("Processing: "+url)rn extracted_data.append(AmzonParser(url))rn sleep(5)rn f=open('data.json','w')rn json.dump(extracted_data,f,indent=4)rnrnrnif __name__ == "__main__":rn ReadAsin()rn[/code] 论坛

关于....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文件啊! 论坛

ubuntu下调用keras报No module named 'error'

09-13

cuda9.0和TensorFlow1.8.0已安装rnimport tensorflow也没有问题,就是再import keras出错,求大神解答!rn报错如下:rnUsing TensorFlow backend.rnTraceback (most recent call last):rn File "/home/zhangzhiyang/PycharmProjects/tensorflow1/test_keras.py", line 2, in rn import kerasrn File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/__init__.py", line 3, in rn from . import utilsrn File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/utils/__init__.py", line 26, in rn from .multi_gpu_utils import multi_gpu_modelrn File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/utils/multi_gpu_utils.py", line 7, in rn from ..layers.merge import concatenatern File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/layers/__init__.py", line 4, in rn from ..engine.base_layer import Layerrn File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/engine/__init__.py", line 7, in rn from .network import get_source_inputsrn File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/engine/network.py", line 9, in rn import yamlrn File "/home/zhangzhiyang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/yaml/__init__.py", line 2, in rn from error import *rnModuleNotFoundError: No module named 'error'rnrnrnrnrn我的版本:tensorflow1.8.0,cuda9.0,cuDNN7,anaconda3,python3.6.5rn我的tensorflow和keras安装路径均为anaconda3/envs/tensorflow/lib/python3.6/site-packagesrnrn我的.bashrc文件如下:rnrnexport PATH="/home/zhangzhiyang/anaconda3/bin:$PATH"rnexport LD_LIBRARY_PATH="/home/zhangzhiyang/newdisk/cuda-9.0/lib64:$LD_LIBRARY_PATH"rnexport PATH="/home/zhangzhiyang/newdisk/cuda-9.0/bin:$PATH"rnexport CUDA_HOME=$CUDA_HOME:"/home/zhangzhiyang/newdisk/cuda-9.0"rnrnrnrn个人推测可能是python版本的问题,但不知如何解决,我第一次pip Keras未指定安装路径,结果keras安装在了python2.7下,这次我指定了路径为python3.6/site_packages,但是报了如上错误,是否keras不支持python3?rnrn求大神解答! 问答

安装xgboost过程中,报ImportError: No module named numpy.distutils.core

04-19

安装xgboost过程中,在Python-package下执行python setup.py install命令时提示rnrnTraceback (most recent call last):rn File "setup.py", line 42, in rn url='https://github.com/dmlc/xgboost')rn File "F:\python2.7.6\lib\distutils\core.py", line 152, in setuprn dist.run_commands()rn File "F:\python2.7.6\lib\distutils\dist.py", line 953, in run_commandsrn self.run_command(cmd)rn File "F:\python2.7.6\lib\distutils\dist.py", line 972, in run_commandrn cmd_obj.run()rn File "build\bdist.win32\egg\setuptools\command\install.py", line 67, in runrn File "build\bdist.win32\egg\setuptools\command\install.py", line 117, in do_egg _installrn File "build\bdist.win32\egg\setuptools\command\easy_install.py", line 411, in r unrn File "build\bdist.win32\egg\setuptools\command\easy_install.py", line 655, in e asy_installrn File "build\bdist.win32\egg\setuptools\command\easy_install.py", line 702, in i nstall_itemrn File "build\bdist.win32\egg\setuptools\command\easy_install.py", line 747, in p rocess_distributionrn File "build\bdist.win32\egg\pkg_resources\__init__.py", line 846, in resolvern File "build\bdist.win32\egg\pkg_resources\__init__.py", line 1118, in best_matc hrn File "build\bdist.win32\egg\pkg_resources\__init__.py", line 1130, in obtainrn File "build\bdist.win32\egg\setuptools\command\easy_install.py", line 674, in e asy_installrn File "build\bdist.win32\egg\setuptools\command\easy_install.py", line 700, in i nstall_itemrn File "build\bdist.win32\egg\setuptools\command\easy_install.py", line 881, in i nstall_eggsrn File "build\bdist.win32\egg\setuptools\command\easy_install.py", line 1120, in build_and_installrn File "build\bdist.win32\egg\setuptools\command\easy_install.py", line 1106, in run_setuprn File "build\bdist.win32\egg\setuptools\sandbox.py", line 258, in run_setuprn File "F:\python2.7.6\lib\contextlib.py", line 35, in __exit__rn self.gen.throw(type, value, traceback)rn File "build\bdist.win32\egg\setuptools\sandbox.py", line 198, in setup_contextrn File "F:\python2.7.6\lib\contextlib.py", line 35, in __exit__rn self.gen.throw(type, value, traceback)rn File "build\bdist.win32\egg\setuptools\sandbox.py", line 169, in save_modulesrn File "build\bdist.win32\egg\setuptools\sandbox.py", line 144, in resumern File "build\bdist.win32\egg\setuptools\sandbox.py", line 157, in save_modulesrn File "build\bdist.win32\egg\setuptools\sandbox.py", line 198, in setup_contextrn File "build\bdist.win32\egg\setuptools\sandbox.py", line 255, in run_setuprn File "build\bdist.win32\egg\setuptools\sandbox.py", line 285, in runrn File "build\bdist.win32\egg\setuptools\sandbox.py", line 253, in runnerrn File "build\bdist.win32\egg\setuptools\sandbox.py", line 47, in _execfilern File "c:\users\admini~1\appdata\local\temp\easy_install-pxqv7f\scipy-0.19.0\set up.py", line 416, in rnrn File "c:\users\admini~1\appdata\local\temp\easy_install-pxqv7f\scipy-0.19.0\set up.py", line 396, in setup_packagernrnImportError: No module named numpy.distutils.corern 论坛

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