ModuleNotFoundError: No module named 'weasyprint' - django

I have installed WeasyPrint==0.42.3, but when I try to import it in Django, it raises the following error:
ModuleNotFoundError: No module named 'weasyprint'
When I look at the requirements.txt, it actually shows that it is installed.
I am using Django==2.1.5, python==3.8.5. another issue I am encountering is, the version of Django I am using is not listed in the requirements.txt, but when I check the version from the terminal, it shows that I am using the above named version.

Related

Python3: AttributeError: module 'boto' has no attribute 'plugin'

I am running some code on a Google Platform Compute Engine VM and I get an error when I imported Python boto library.
The first time if I run 'import boto', the error message would be:
ModuleNotFoundError: No module named 'urllib2'
Then I ran it again, a different error message came out:
AttributeError: module 'boto' has no attribute 'plugin'
I tried installing google-compute-engine but it didn't work. I also tried different versions of boto but failed as well.
As it is suggested by user10360186 in AttributeError: module 'boto' has no attribute 'plugin' answer. You have to execute
$ pip install google-compute-engine
and restart the VM.
Problem solved. Not sure why but when you try to use boto on a google platform engine. There will be a file /usr/share/google/boto/boto_plugins/compute_auth.py, you need to modify the line from 'import urllib2' to 'import urllib.request as urllib2' to fit Python3. Then it is all good.

Python Django error related to urllib3

Error:
ImportError: No module named packages.urllib3.poolmanager
I have set requests module in requirements.txt like this:
requests>=2.5.1
requests contains another version of urllib3. What could be going wrong?
Can you add your error traceback message?
from requests.packages.urllib3.poolmanager import PoolManager
See if the above solves it
This was caused by not using virtualenv. It was resorting to the system python which was causing this error.

django in virtaul environment giving ImportError

if i run
(My_Virtual_Env) G:\My-Project\My_Code>python ..\My_Virtual_Env\Scripts\django-admin.py startproject My_django_project
its working fine and new project is getting created.
But when i run
(My_Virtual_Env) G:\My-Project\My_Code>django-admin.py startproject My_django_project
am getting error
ImportError: No module named django.core
i want to know why it is happening ? and what are the changes need to do to run second command as it is ?
The My_Virtual_Env/Scripts folder is not added to the classpath by default. That is why you get that error. If you install django, the directory of this will directly be added to classpath. Why do you execute from another place?

Import error web "no module named web"

I did an web application using web.py and after a while I realize that my python compiler was configure to use python2 instead of python3 (both are installed). With python2 my application was working but I got string in unicode so I try to execute my code using python3:
python3 mycode.py
But I get different kind of error, the lib urlparse was not found (this problem was cause by a new name in python3 which is urllib) but I got a problem with:
import web
The return error is:
ImportError: No module named 'web'
I can't figure out where the problem come from.
Web.py cannot work with python3, this is the linked to the gitub project.
https://github.com/webpy/webpy/issues/108
Maybe you have installed web in your python2 lib but you have none in python3 lib... Check it out

No module named middleware for django-bouncer

I'm using django-bouncer to make a waiting list in a Django 1.6 app. Unfortunately, when I add 'bouncer.middleware.MembersOnlyMiddleware' to my MIDDLEWARE_CLASSES as required, I get: "ImportError: No module named middleware." I tried going into the Django shell and typing "from bouncer.middleware import MembersOnlyMiddleware," but that received the same error.
What can I do to resolve this problem?
django-bouncer and bouncer are not the same package.
Try to install django-bouncer:
pip install django-bouncer