我尝试psycopg2
使用virtualenv 安装pip
,编译看起来没问题,它说"成功安装了psycopg2",但是当我尝试在python解释器中导入它时(在virtualenv中),它表示错误:
File "<stdin>", line 1, in <module>
File "/Users/me/sites/env/trackmap/lib/python2.7/site-packages/psycopg2/__init__.py", line 67, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: dlopen(/Users/me/sites/env/trackmap/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: libssl.dylib
Referenced from: /Users/me/sites/env/trackmap/lib/python2.7/site-packages/psycopg2/_psycopg.so
Reason: Incompatible library version: _psycopg.so requires version 1.0.0 or later, but libssl.0.9.8.dylib provides version 0.9.8
Run Code Online (Sandbox Code Playgroud)
问题是我pip
在几周之前使用我的其他虚拟环境成功安装它,就像几个星期前一样,让它postgresql
在我的Mac上工作.我想知道这是否是编译器的问题?我shortens from 64-bit to 32-bit
在安装psycopg2时看到了一些警告.我的编译器是i686-apple-darwin11-llvm-gcc-4.2
mac os x lion上的默认编译器.
我看到几个与psycopg2
安装相关的帖子,但大多数都是通过安装在虚拟环境中解决的.那么......有人能给我一个建议吗?谢谢!非常感谢.
ps如果你需要安装psycopg2的编译日志,请告诉我,我没有在这里粘贴,因为它太长了.
我正在使用gunicorn + Nginx运行Flask Web应用程序.我在daemon
模式中运行gunicorn .我配置了gunicorn和nginx来记录他们对文件的访问和错误.但我无法将Flask日志记录到文件中.
我使用shell文件用gunicorn启动我的应用程序:
#!/bin/bash
export VIRTUAL_ENV="/to/virtual/path"
export PATH="$VIRTUAL_ENV/bin:$PATH"
source "$VIRTUAL_ENV/bin/activate"
NAME="hello"
NUM_WORKERS=1
exec gunicorn hello:app \
--name $NAME \
--workers $NUM_WORKERS \
--log-level=debug \
--daemon \
--pid $VIRTUAL_ENV/logs/pid_gunicorn \
--access-logfile $VIRTUAL_ENV/logs/access_gunicorn.log \
--error-logfile $VIRTUAL_ENV/logs/error_gunicorn.log
Run Code Online (Sandbox Code Playgroud)
在我的烧瓶应用程序中,我根据文档要求添加日志记录:
app.debug = False
...
if __name__ == '__main__':
if app.debug != True:
import logging
from logging.handlers import RotatingFileHandler
handler = RotatingFileHandler("flask.log", maxBytes=10000, backupCount=1)
handler.setLevel(logging.DEBUG)
app.logger.addHandler(handler)
app.logger.debug("test!!")
app.run()
Run Code Online (Sandbox Code Playgroud)
我还在app.logger.debug
其他地方添加了.
当我gunicorn
没有开始时--daemon
,日志文件工作正常.但是一旦我添加,--daemon
就不会生成任何日志.
我尝试使用,print
但它只能没有 …
我正在学习delang中的延迟行为,并希望在函数返回时使用它来处理错误.
代码如下:
package main
import "fmt"
import "errors"
func main() {
a()
}
func a() {
var err error
defer func(){
if err != nil {
fmt.Printf("1st defer: %s\n", err)
} else {
fmt.Println("1st defer: defer not error")
}
}()
defer func(err error){
if err != nil {
fmt.Printf("2nd defer: %s\n", err)
} else {
fmt.Println("2nd defer: defer not error")
}
}(err)
err = errors.New("new error")
if err != nil {
return
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
2nd defer: defer not error …
Run Code Online (Sandbox Code Playgroud)