Beste mede-tweakers!
Ik ben tegen een probleem aangelopen met cherrypy voor python. Als ik cherry wil importeren vanuit een lib folder dan werkt cherry niet correct (zie test2.py) Echter als ik cherrypy importeer vanuit hetzelfde niveau als de executable (test.py) dan werkt het correct. Zou iemand mij dit kunnen uitleggen waarom het niet werkt? In de lib folder is een lege __init__.py aanwezig.
test.py
Output test.py
test2.py
Output test2.py
Ik ben tegen een probleem aangelopen met cherrypy voor python. Als ik cherry wil importeren vanuit een lib folder dan werkt cherry niet correct (zie test2.py) Echter als ik cherrypy importeer vanuit hetzelfde niveau als de executable (test.py) dan werkt het correct. Zou iemand mij dit kunnen uitleggen waarom het niet werkt? In de lib folder is een lege __init__.py aanwezig.
test.py
code:
1
2
3
4
5
6
7
8
| import cherrypy options_dict = { 'log.screen': True, 'server.socket_port': 8797, } cherrypy.config.update(options_dict) cherrypy.server.start() cherrypy.engine.exit() |
Output test.py
code:
1
2
3
4
5
6
7
8
9
| C:\Users\Bob\Programming\Hoarder>python test.py [05/Feb/2014:16:54:09] ENGINE Serving on 127.0.0.1:8797 [05/Feb/2014:16:54:09] ENGINE Bus STOPPING [05/Feb/2014:16:54:09] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('127.0.0.1', 8797)) shut down [05/Feb/2014:16:54:09] ENGINE No thread running for None. [05/Feb/2014:16:54:09] ENGINE No thread running for None. [05/Feb/2014:16:54:09] ENGINE Bus STOPPED [05/Feb/2014:16:54:09] ENGINE Bus EXITING [05/Feb/2014:16:54:09] ENGINE Bus EXITED |
test2.py
code:
1
2
3
4
5
6
7
8
| import libs.cherrypy as cherrypy options_dict = { 'log.screen': True, 'server.socket_port': 8797, } cherrypy.config.update(options_dict) cherrypy.server.start() cherrypy.engine.exit() |
Output test2.py
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| C:\Users\Bob\Programming\Hoarder>python test2.py [05/Feb/2014:16:55:18] ENGINE Serving on 127.0.0.1:8080 [05/Feb/2014:16:55:18] ENGINE Serving on 127.0.0.1:8080 [05/Feb/2014:16:55:18] ENGINE Bus STOPPING [05/Feb/2014:16:55:18] ENGINE Bus STOPPING [05/Feb/2014:16:55:18] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('127.0.0.1', 8080)) shut down [05/Feb/2014:16:55:18] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('127.0.0.1', 8080)) shut down [05/Feb/2014:16:55:18] ENGINE HTTP Server None already shut down [05/Feb/2014:16:55:18] ENGINE HTTP Server None already shut down [05/Feb/2014:16:55:18] ENGINE No thread running for None. [05/Feb/2014:16:55:18] ENGINE No thread running for None. [05/Feb/2014:16:55:18] ENGINE No thread running for None. [05/Feb/2014:16:55:18] ENGINE No thread running for None. [05/Feb/2014:16:55:18] ENGINE No thread running for None. [05/Feb/2014:16:55:18] ENGINE No thread running for None. [05/Feb/2014:16:55:18] ENGINE No thread running for None. [05/Feb/2014:16:55:18] ENGINE No thread running for None. [05/Feb/2014:16:55:18] ENGINE Bus STOPPED [05/Feb/2014:16:55:18] ENGINE Bus STOPPED [05/Feb/2014:16:55:18] ENGINE Bus EXITING [05/Feb/2014:16:55:18] ENGINE Bus EXITING [05/Feb/2014:16:55:18] ENGINE Bus EXITED [05/Feb/2014:16:55:18] ENGINE Bus EXITED |