草庐IT

global_mod

全部标签

python - Django + mod_wsgi + apache : ImportError at/No module named djproj. 网址

我正在尝试使用apache和mod_wsgi在我的linode服务器上部署我的Django应用程序。文件:/srv/www/example.com/djproj/django.wsgiimportosimportsyssys.path.append('/srv/www/example.com/djproj')os.environ['PYTHON_EGG_CACHE']='/srv/www/example.com/.python-egg'os.environ['DJANGO_SETTINGS_MODULE']='settings'importdjango.core.handlers.ws

python - 机器人框架 : access Robot's global variables from Python library code?

我有一些设置类型的全局变量,我希望能够从Python代码访问这些变量。例如:pybot--variableRESULTS_PATH:/wherever/this/pointstest.txt现在,我的模块logger.py文件需要知道results_path才能正确设置。我知道我可以用变量初始化记录器,比如***Settings***Librarylogger${RESULTS_PATH}然后在记录器中我将传递results_path:def__init__(self,results_path):#Whatever但是对我来说这样做的问题是我想从Python代码和测试用例中访问和使用记

python - 无法解决 Django 设置中的 mod_wsgi 异常

我正在与我的托管服务提供商合作来启动和运行Django应用程序,但我们都不是很有经验,我们基本上已经走到了死胡同。我没有直接访问conf文件的权限,但这是我对它的内容的描述:WSGIScriptAlias/fredapp//home/fred/public_html/cgi-bin/fredapp/apache/django.wsgiWSGIDaemonProcessfredthreads=15display-name=%{GROUP}python-path=/home/fred/public_html/cgi-bin/fredapp/apache/WSGIProcessGroupfr

python - Apache mod_wsgi 错误 : Forbidden You don't have permission to access/on this server

我正在使用Ubuntu10.04。我在/home/wong2/Code/python/django2/下创建了一个名为atest的django项目并在同一目录下创建一个wsgi文件setting.wsgi以下是setting.wsgi的内容:importosimportsyspath='/home/wong2/Code/python/django2'ifpathnotinsys.path:sys.path.append(path)os.environ["DJANGO_SETTINGS_MODULE"]="atest.settings"fromdjango.core.handlers.w

python - 如何将 conda 环境与 mod_wsgi 一起使用?

我的第一篇文章,我是Python和Apache的新手,所以请放轻松。我在conda环境中有一个PythonWeb应用程序,使用Flask可以很好地提供内容。现在我需要使用Apache而不是Flask来提供所有服务。我可以让Apache使用mod_wsgi运行Python,但只能使用virtualenv。我尝试使用Anaconda安装virtualenv,但我收到一条警告,指出此类设置不受支持且不推荐。所以我的问题是:如何设置Apache以在conda环境中运行我的应用程序?Here,有一个关于使用虚拟环境的部分,它说我需要在我的wsgi文件中输入一行来显示在哪里可以找到activate

python - 如何将 Flask 路由与 Apache 和 mod_wsgi 一起使用?

我已经设置了Apache服务器,它正在通过mod_wsgi处理Flask响应。我已经通过别名注册了WSGI脚本:[httpd.conf]WSGIScriptAlias/service"/mnt/www/wsgi-scripts/service.wsgi"我在上面的路径下添加了对应的WSGI文件:[/mnt/www/wsgi-scripts/service.wsgi]importsyssys.path.insert(0,"/mnt/www/wsgi-scripts")fromserviceimportapplication我有一个提供服务模块的简单测试FlaskPython脚本:[/mn

python - mod_wsgi 不支持 WSGIPythonHome

我正在尝试让WSGI使用virtualenv设置运行。我的virtualenv一切正常:(virtualenv)dev:/var/www/app$whichpython/var/www/virtualenv/bin/python(virtualenv)dev:/var/www/app$pythonPython2.6.1(r261:67515,Dec52008,22:09:34)[GCC4.1.2]onlinux2Type"help","copyright","credits"or"license"formoreinformation.>>>importimportlib>>>在我的ht

Python: "global name ' 时间'未定义”

我正在为一个打印“Wearetheknightswhosay'Ni'!”的friend用Python编写一个愚蠢的程序。然后休眠3秒,然后打印“Ni!”使用random模块的uniform()方法以随机间隔执行二十次。这是我的代码:fromtimeimportsleepimportrandomdefknights_of_ni():generator=random.Random()print"Wearetheknightswhosay'ni'."sleep(3)foriinrange(0,20):print"Ni!"sleep(generator.uniform(0,2))我尝试通过在解

使用 mod_wsgi 的 Python POST 数据

这一定是个很简单的问题,但我好像想不通。我正在使用apache+mod_wsgi来托管我的python应用程序,我想获得以其中一种形式提交的帖子内容-但是,环境值和sys.stdin都不包含任何此类数据。介意快点帮我吗?编辑:已经试过了:environ["CONTENT_TYPE"]='application/x-www-form-urlencoded'(无数据)environ["wsgi.input"]似乎是一种合理的方式,然而,environ["wsgi.input"].read()和environ["wsgi.input"].read(-1)都返回一个空的string(是的,内容

python - 名称错误 : global name 'HTTPError' is not defined

我在try子句中有一个命令,我知道它会引发异常。我试图在“except”子句中捕获它,但except子句似乎不承认异常的存在。未处理的异常(即未包含在try子句中)在交互窗口中看起来像这样:Traceback(mostrecentcalllast):File"",line1,inFile"C:\Users\Andy\software\Turkeys\actions.py",line234,inannotateannotation=annotator.ncbo_annotate(thing)File"C:\Users\Andy\software\Turkeys\annotator.py"