Ненормальное поведение пакета python накануне - PullRequest
0 голосов
/ 02 января 2019

Я установил пакет eve на свой компьютер с Windows, но каждый раз, когда я выключаю компьютер и пытаюсь загрузить пакет eve, я получаю сообщение об ошибке модуль не найден.

При попытке переустановки (кстати, я установил последнюю версию pip для установки), я получаю

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".Если это проблема, как мне ее исправить?

Однако приведенный ниже код работает, но работает для микросекций, а не для запуска внутреннего сервера с API:

from eve import Eve
app=Eve
app.run

Настройки.py файл:

# 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,
}

Итак, что может быть решением этой проблемы?

Любая помощь приветствуется.

1 Ответ

0 голосов
/ 03 января 2019

У меня нет этой проблемы после быстрого теста. Позвольте мне поделиться с вами всеми шагами и сообщить, что все по-другому.

1) Введите Anaconda Prompt

2) conda create -n eswar python = 3.6

3) Conda Activate ESWAR

4) pip install канун

5) питон

5.1) канун импорта

5.2) выход ()

6) выключение окон машины

7) перезагрузить windows machine

8) введите подсказку анаконды

9) Конда активировать Эсвар

10) питон

11) из канун импорта Ева

12) все выглядит хорошо.

Вы забыли активировать свою среду после перезагрузки?

...