首页 \ 问答 \ index.wsgi没有在root中找到virtualenv(index.wsgi not finding virtualenv in root)

index.wsgi没有在root中找到virtualenv(index.wsgi not finding virtualenv in root)

我正在尝试按照本教程在Apache VPS上安装django站点
我的index.wsgi应该在root中激活virtualenv,它看起来像这样:

import os
import sys
import site

# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('~/.virtualenvs/DBENV/local/lib/python2.7/site-packages')

# Add the app's directory to the PYTHONPATH
sys.path.append('/home/DB2015/')
sys.path.append('/home/DB2015/davidcms/')

os.environ['DJANGO_SETTINGS_MODULE'] = 'davidcms.settings'

# Activate your virtual env
activate_env=os.path.expanduser("~/.virtualenvs/DBENV/bin/activate_this.py")
execfile(activate_env, dict(__file__=activate_env))

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

我收到这个错误

[Tue Feb 17 07:13:30.701511 2015] [:error] [pid 16103:tid 140396130674432]           [client 217.44.75.146:58169]     execfile(activate_env, dict(__file__=activate_env))
[Tue Feb 17 07:13:30.701653 2015] [:error] [pid 16103:tid 140396130674432] [client 217.44.75.146:58169] IOError: [Errno 2] No such file or directory: '/var/www/.virtualenvs/DBENV/bin/activate_this.py'

所以它在var/www/而不是root中查找。 当我尝试将os.path.expanduser更改为根目录中的.virtualenvs路径时:

# Activate your virtual env
activate_env= "~/.virtualenvs/DBENV/bin/activate_this.py"
execfile(activate_env, dict(__file__=activate_env))

它仍然说

[Tue Feb 17 07:17:12.019641 2015] [:error] [pid 16104:tid 140396206208768] [client 217.44.75.146:58200]     execfile(activate_env, dict(__file__=activate_env))
[Tue Feb 17 07:17:12.019852 2015] [:error] [pid 16104:tid 140396206208768] [client 217.44.75.146:58200] IOError: [Errno 2] No such file or directory: '~/.virtualenvs/DBENV/bin/activate_this.py'

我错过了什么?!


I am trying to install a django site on an Apache VPS, following this tutorial
my index.wsgi should activate a virtualenv in the root, it looks like this:

import os
import sys
import site

# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('~/.virtualenvs/DBENV/local/lib/python2.7/site-packages')

# Add the app's directory to the PYTHONPATH
sys.path.append('/home/DB2015/')
sys.path.append('/home/DB2015/davidcms/')

os.environ['DJANGO_SETTINGS_MODULE'] = 'davidcms.settings'

# Activate your virtual env
activate_env=os.path.expanduser("~/.virtualenvs/DBENV/bin/activate_this.py")
execfile(activate_env, dict(__file__=activate_env))

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

and I get this error

[Tue Feb 17 07:13:30.701511 2015] [:error] [pid 16103:tid 140396130674432]           [client 217.44.75.146:58169]     execfile(activate_env, dict(__file__=activate_env))
[Tue Feb 17 07:13:30.701653 2015] [:error] [pid 16103:tid 140396130674432] [client 217.44.75.146:58169] IOError: [Errno 2] No such file or directory: '/var/www/.virtualenvs/DBENV/bin/activate_this.py'

So its looking in var/www/ instead of the root. When I try to change os.path.expanduser to just the path to .virtualenvs in the root as such:

# Activate your virtual env
activate_env= "~/.virtualenvs/DBENV/bin/activate_this.py"
execfile(activate_env, dict(__file__=activate_env))

it still says

[Tue Feb 17 07:17:12.019641 2015] [:error] [pid 16104:tid 140396206208768] [client 217.44.75.146:58200]     execfile(activate_env, dict(__file__=activate_env))
[Tue Feb 17 07:17:12.019852 2015] [:error] [pid 16104:tid 140396206208768] [client 217.44.75.146:58200] IOError: [Errno 2] No such file or directory: '~/.virtualenvs/DBENV/bin/activate_this.py'

What am I missing?!


原文:https://stackoverflow.com/questions/28561390
更新时间:2023-03-21 06:03

最满意答案

以下是http://gruntjs.com/creating-tasks的示例

任务可以是异步的。

grunt.registerTask('asyncfoo', 'My "asyncfoo" task.', function() {
    // Force task into async mode and grab a handle to the "done" function.
    var done = this.async();
    // Run some sync stuff.
    grunt.log.writeln('Processing task...');
    // And some async stuff.
    setTimeout(function() {
        grunt.log.writeln('All done!');
        done();
    }, 1000);
});

Here is an example from http://gruntjs.com/creating-tasks

Tasks can be asynchronous.

grunt.registerTask('asyncfoo', 'My "asyncfoo" task.', function() {
    // Force task into async mode and grab a handle to the "done" function.
    var done = this.async();
    // Run some sync stuff.
    grunt.log.writeln('Processing task...');
    // And some async stuff.
    setTimeout(function() {
        grunt.log.writeln('All done!');
        done();
    }, 1000);
});

相关问答

更多
  • grunt.initConfig({ clean: {/!* clean task configuration *!/}, copy: {/!* copy task configuration *!/}, compass: {/!* compass task configuration *!/}, cssmin: {/!* cssmin task configuration *!/} }); grunt.registerTask('theme', function () { ...
  • 我遵循了MikeC的建议并将grunt-notify包更新到了0.4.5版,现在它就像一个魅力一样工作! I followed MikeC advice and updated the grunt-notify package to version 0.4.5 and now it is working like a charm!
  • 以下是http://gruntjs.com/creating-tasks的示例 任务可以是异步的。 grunt.registerTask('asyncfoo', 'My "asyncfoo" task.', function() { // Force task into async mode and grab a handle to the "done" function. var done = this.async(); // Run some sync stuff. gr ...
  • 您需要单独调用loadNpmTasks : grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-connect'); 您只能使用loadNpmTasks一次加载一个插件。 You need to make separate calls to loadNpmTasks: grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt- ...
  • 后: 删除和克隆回购。 删除npm_modules。 重新安装一切。 创建一个独立的项目来测试此问题。 由于@XavierPriour的评论,我们检查了咕噜咕噜的路径 在iTerm中使用zsh: ➜ folder git:(branch) which grunt /usr/local/bin/grunt ➜ folder git:(branch) type -a grunt grunt is /usr/local/bin/grunt grunt is /usr/bin/grunt 我们删除了额外的gr ...
  • 显然,这篇文章: Grunt LiveReload真的很慢,讨论同样的问题,我相信它解决了它。 如果有帮助的话,我还要尝试一下并更新这篇文章。 Apparently, this post: Grunt LiveReload is really slow discusses the same problem and I believe it solves it. I'm yet to try it out and update this post if it helps.
  • 因此,您实际上从未运行browserify任务。 当您在命令行上运行grunt而未指定特定任务时,它会运行default任务,在这种情况下只运行connect和watch 。 有两种方法可以解决: 只需在命令行上调用grunt browserify即可 将默认任务更改为: ['browserify', 'connect', 'watch'] So, you are never actually running the browserify task. When you run grunt on the co ...
  • 你试过从命令提示符运行bower安装吗? 你是如何生成项目支架的? Bower.json,package.json和gruntfile.js应该在你的根目录中。 这是生成项目支架并使用grunt和bower运行应用程序的最佳方法。 http://yeoman.io/codelab/setup.html 我希望这能帮到您。 did you tried running bower install from command prompt? How did you generated your project sc ...
  • 在第22行, https://github.com/gruntjs/grunt/blob/master/lib/grunt/fail.js,您可以找到“哔”行的示例。 如果你对嘟嘟声感到恼火,想要消除周围的所有哔哔声,那就试着把它放在一边 grunt.option('no-color',true) 在你的gruntfile中,所以该行 if(!grunt.option('no-color')){msg + ='\ x07'; } 永远不会发生。 On line 22, https://github.com/ ...
  • 这只是我们所拥有的文件夹的命名约定 dist是存储生成的档案的文件夹(因此它通过清理和构建进行更新)。 build文件夹包含已编译的类和资源,但不包含压缩的存档。 It's just a naming conventions for folders like in java we have dist is the folder where your generated archives are stored (so it gets updated through clean and build). buil ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。