简体   繁体   中英

Raspberry Pi django server ImportError cannot import name 'etree'

I'm trying to setup Django project on Raspberry Pi to serve a framework on a local network. I have succesfuly installed Django, it is starting with apache2 and all computers on network can see default Django "It worked" page. After I load my app, I'm getting the web page with error: ImportError cannot import name 'etree' at location /home/pi/Django/Ponude/lib/python3.6/site-packages/docx/opc/oxml.py in <module>, line 12

I have installed with pip all necessery modules, here is all from pip freeze:

Django==2.2.3
lxml==3.6.0
Pillow==6.1.0
python-docx==0.8.10
pytz==2019.1
sqlparse==0.3.0

When I try to import modules manually in shell, there is no problem importing, only when starting django. I have tried uninstalling and installing all modules, but no help. I also searched Stack Overflow, but found nothing similar or nothing that helped. Can somebody please help me? Is it maybe about permissions or apache2 config? I'n case it helps, here is my apache2 config:

<VirtualHost *:80>
    ServerName www.example.com

    ServerAdmin webmaster@localhost


    Alias /static /home/pi/Django/Ponude/Ponude/static
        <Directory /home/pi/Django/Ponude/Ponude/static>
           Require all granted
         </Directory>

    <Directory /home/pi/Django/Ponude/Ponude/Ponude>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    WSGIDaemonProcess Ponude python-path=/home/pi/Django/Ponude/Ponude:/home/pi/Django/Ponude/lib/python3.6/site-packages
    WSGIProcessGroup Ponude
    WSGIScriptAlias / /home/pi/Django/Ponude/Ponude/Ponude/wsgi.py

</VirtualHost>

Thank you

EDIT: Also when I start the Django manually with python manage.py runserver command, there is no error

So... Apache2 was running on Python 3.5 even though I installed 3.6 and Venv had 3.6 and I have explicitly set to the 3.6 python path.

I have fixed this problem by creating new venv and running all in python 3.5.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM