我正在尝试在Ubuntu上使用PyMySQL.
我已经安装了pymysql两个pip,pip3但每次使用import pymysql时都会返回ImportError: No module named 'pymysql'
我正在使用Ubuntu 15.10 64位和Python 3.5.
同样的.py可以在Windows上使用Python 3.5,但不适用于Ubuntu.
我正在尝试启动我使用systemd编写的瓶子web应用程序.我用/etc/systemd/user/bottle.service以下内容制作了文件:
[Unit]
Description=Bottled fax service
After=syslog.target
[Service]
Type=simple
User=fax
Group=fax
WorkingDirectory=/home/fax/bottlefax/
ExecStart=/usr/bin/env python3 server.py
StandardOutput=syslog
StandardError=syslog
Restart=always
RestartSec=2
[Install]
WantedBy=bottle.target
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试启动它时,它会失败,并打印在journalctl:
Jun 10 17:33:31 nano systemd[1]: Started Bottled fax service.
Jun 10 17:33:31 nano systemd[1]: Starting Bottled fax service...
Jun 10 17:33:31 nano systemd[2380]: Failed at step GROUP spawning /usr/bin/env: No such process
Jun 10 17:33:31 nano systemd[1]: bottle.service: main process exited, code=exited, status=216/GROUP
Jun 10 17:33:31 nano systemd[1]: Unit bottle.service entered failed state.
Jun 10 …Run Code Online (Sandbox Code Playgroud) 我在Python 3.4中创建了一个Enum,其中包含一些数据和一个基于枚举返回ffactor的函数.我想从每个Enum制作一个ffactors字典.所以我尝试了这个:
class RaceType(Enum):
GS = 0
SC = 1
CL = 2
@property
def ffactor(self):
if self is RaceType.GS:
return 660.0
if self is RaceType.SC or self is RaceType.CL:
return 500.0
zeroes = {this: this.ffactor() for this in RaceType}
Run Code Online (Sandbox Code Playgroud)
但是,这引发了一个错误:
Traceback (most recent call last):
File "parse.py", line 28, in <module>
zeroes = {this: this.ffactor() for this in RaceType}
File "parse.py", line 28, in <dictcomp>
zeroes = {this: this.ffactor() for this in RaceType}
TypeError: 'float' object is not callable …Run Code Online (Sandbox Code Playgroud)