python - 在类中加载外部模块时无法加载 apache 服务器

标签 python django apache web-applications beautifulsoup

这是我的 django 项目层次结构

project/
       apache/ django.wsgi
       project/ __init__.py, settings.py, urls.py ..
       pages/
             __init__.py
             widgets.py
             website_views.py
       services/
               __init__.py
               apis/
                    __init__.py
                    fparser.py
                    googleData.py
                    wp.py
                    ...
               wservice.py
       ...

因此,wservice.py 是一个类似于类的包装,位于 apis 模块的所有类之上。它甚至为它继承的所有类提供一些通用功能。

wservice.py

import feedparser
from bs4 import BeautifulSoup

class WidgetService(FParser):
    def post_content_summary(self, post_number):   
        ....
        content_text = content_soup.get_text()

        ...

    def get_random_image(self, post_number):
        ...
        content_soup = BeautifulSoup(html_content)

        ...

FParser 类位于 fparser.py

fparser.py中的方法以这种方式使用上面的类。

from services.wservice import WidgetService
def method1():
    obj = WidgetService()
    m1 = obj.foo1() # described in FParser class
    m2 = obj.foo2() # described in WidgetService class

我在pages/widgets.py中使用这个WidgetService()。所以,我发现,当我开始使用 BeautifulSoup 时,apache 服务器不会加载。它甚至没有显示任何语法错误。

我什至在日志文件中没有看到任何错误。

可能出了什么问题???有趣的是,我在开发服务器heroku(gunicorn)中没有遇到过这种错误

最佳答案

这可能就是所描述的 Cython 和 mod_wsgi 之间的交互 ​​here ,并在 Beautiful Soup 上下文中进行探索 here 。这是an earlier question和你的类似。

关于python - 在类中加载外部模块时无法加载 apache 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11398911/

相关文章:

python - Django REST to_representation : Have serializer fields appear last

java - 使用 Apache POI 更新 excel 文件

linux - Httpd 配置 -- 访问文件夹

python - 获取AWS S3中所有存储桶的名称和数量

python 诅咒 tty 屏幕闪烁

python - 有没有办法在 Altair 上可视化时间序列数据帧,其中变量是标题?

python - Django - 对象的社交类权限

python - Wagtail 管理模板中的 render() 意外关键字错误

php - Apache不会请求我的SSL客户端证书

python - 将 Django TimeField 中的时间乘以 float