模块未找到错误:Python中没有名为gothonweb2的模块

2024-10-01 19:27:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我的错误是

(base) C:\Users\lenovo\projects\gothonweb2>python bin/app.py
Traceback (most recent call last):
  File "bin/app.py", line 2, in <module>
    from gothonweb2 import map
ModuleNotFoundError: No module named 'gothonweb2'

项目目录是

C:\Users\lenovo\projects\gothonweb2

^{pr2}$

bin中的代码/应用程序副本是:

import web
from gothonweb2 import map
import urllib.request
urls=(
    '/game','GameEngine',
    '/','Index',
)
app=web.application(urls,globals())
#Title hack so that debug mode works with sessions
if web.config.get('_session') is None:
    store=web.session.DiskStore('sessions')
    session=web.session.Session(app,store,initializer={'room':None})
    web.config._session=session
else:
    session=web.config._session
render=web.template.render('templates/',base="layout")
class Index(object):
    def GET(self):
    #this is use to"setup"the session with starting values
        session.room=map.START
        web.seeother("/game")
class GameEngine(object):
    def GET(self):
        if session.room:
            return render.show_room(room=session.room)
        else:
            return render.you_died()
    def POST(self):
        form=web.input(action=None)
        #there is a bug here,can you fix it?
        if session.room and form.action:
            session.room=session.room.go(form.action)
        web.seeother("/game")
if __name__=="__main__":
    app.run()

我得到的错误和上面一样。此外,项目的路径和导入gothonweb2部分也在上面。我不知道它为什么返回'No module named'gothonweb2'。有人能帮我吗?在


Tags: importnonewebgameconfigappmapif

热门问题