python包eve的异常行为 [英] Abnormal behavior of python package eve
问题描述
我已经在Windows机器上安装了eve软件包,但是每次我关闭机器并尝试加载eve软件包时,都会出现找不到模块错误.
I have installed the eve package on my windows machine but every time I shutdown the machine and try to load the eve package I get module not found error.
在尝试重新安装时(顺便说一句,我使用最新的pip版本进行安装),我得到
On re-installation attempt(Btw I used the latest pip version to install), I get
from eve import Eve
app=Eve()
app.run()
错误指向第二行.
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-79-46d1b24866c8> in <module>()
30 # host = '127.0.0.1'
31
---> 32 app = Eve()
33 # app.run()
34
~\AppData\Local\Continuum\anaconda3\lib\site-packages\eve\flaskapp.py in __init__(self, import_name, settings, validator, data, auth, redis, url_converters, json_encoder, media, **kwargs)
158 self.settings = settings
159
--> 160 self.load_config()
161 self.validate_domain_struct()
162
~\AppData\Local\Continuum\anaconda3\lib\site-packages\eve\flaskapp.py in load_config(self)
275
276 try:
--> 277 self.config.from_pyfile(pyfile)
278 except:
279 raise
~\AppData\Local\Continuum\anaconda3\lib\site-packages\flask\config.py in from_pyfile(self, filename, silent)
128 try:
129 with open(filename, mode='rb') as config_file:
--> 130 exec(compile(config_file.read(), filename, 'exec'), d.__dict__)
131 except IOError as e:
132 if silent and e.errno in (
~\AppData\Local\Continuum\anaconda3\lib\site-packages\bokeh\settings.py in <module>()
9 from os.path import join, abspath, isdir
10
---> 11 from .util.paths import ROOT_DIR, bokehjsdir
12
13
ModuleNotFoundError: No module named 'config'
此外,我发现没有文件夹"lib",而是"Lib".如果这是问题,我该如何纠正?
Moreover, I find that there is no folder "lib" but "Lib". If this is the problem how do I rectify it?
但是,下面的代码可以运行,但运行时间为微秒,这与使用api运行后端服务器不同:
However, the code below works but runs for microsecs, not like running a back-end server with api's:
from eve import Eve
app=Eve
app.run
settings.py文件:
The settings.py file:
# Let's just use the local mongod instance. Edit as needed.
# Please note that MONGO_HOST and MONGO_PORT could very well be left
# out as they already default to a bare bones local 'mongod' instance.
MONGO_HOST = 'localhost'
MONGO_PORT = 27017
MONGO_DBNAME = 'apitest'
# Enable reads (GET), inserts (POST) and DELETE for resources/collections
# (if you omit this line, the API will default to ['GET'] and provide
# read-only access to the endpoint).
RESOURCE_METHODS = ['GET', 'POST', 'DELETE']
# Enable reads (GET), edits (PATCH), replacements (PUT) and deletes of
# individual items (defaults to read-only item access).
ITEM_METHODS = ['GET', 'PATCH', 'PUT', 'DELETE']
people = {
# 'title' tag used in item links.
'item_title': 'person',
# by default the standard item entry point is defined as
# '/people/<ObjectId>/'. We leave it untouched, and we also enable an
# additional read-only entry point. This way consumers can also perform GET
# requests at '/people/<lastname>/'.
'additional_lookup': {
'url': 'regex("[\w]+")',
'field': 'lastname'
},
'cache_control': 'max-age=10,must-revalidate',
'cache_expires': 10,
'resource_methods': ['GET', 'POST'],
# Schema definition, based on Cerberus grammar. Check the Cerberus project
# (https://github.com/pyeve/cerberus) for details.
'schema': {
'firstname': {
'type': 'string',
'minlength': 1,
'maxlength': 10,
},
'lastname': {
'type': 'string',
'minlength': 1,
'maxlength': 15,
'required': True,
# talk about hard constraints! For the purpose of the demo
# 'lastname' is an API entry-point, so we need it to be unique.
'unique': True,
},
# 'role' is a list, and can only contain values from 'allowed'.
'role': {
'type': 'list',
'allowed': ["author", "contributor", "copy"],
},
# An embedded 'strongly-typed' dictionary.
'location': {
'type': 'dict',
'schema': {
'address': {'type': 'string'},
'city': {'type': 'string'}
},
},
'born': {
'type': 'datetime',
},
}
}
DOMAIN = {
'people': people,
}
那么,该问题的解决方案是什么?
So, What could be the solution to this problem?
感谢您的帮助.
推荐答案
快速测试后,我没有这个问题.让我与您分享所有步骤,让我知道所有不同之处.
I don't have this issue after a quick test. Let me share with you all steps and let me know anything is different.
1)输入Anaconda提示
1) Enter Anaconda Prompt
2)康达创建-n eswar python = 3.6
2) conda create -n eswar python=3.6
3)conda激活eswar
3) conda activate eswar
4)点安装前夕
5)python
5.1)导入前夕
5.2)exit()
5.2) exit()
6)关闭Windows计算机
6) shutdown windows machine
7)重新启动Windows计算机
7) restart windows machine
8)输入anaconda提示
8) enter anaconda prompt
9)conda激活eswar
9) conda activate eswar
10)python
10) python
11)从前夕导入前夕
11) from eve import Eve
12)一切看起来都很好.
12) everything looks fine.
重启后您是否忘记激活环境?
did you forget to activate your env after restart?
这篇关于python包eve的异常行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!