ResolutionImpossible - Conflicting dependencies while deploying on heroku - django

While deploying a Django + React project on Heroku, this error occoured:
The conflict is caused by:
djoser 2.1.0 depends on social-auth-app-django<5.0.0 and >=4.0.0
rest-social-auth 8.0.0 depends on social-auth-app-django<6.0 and >=5.0
If I downgrade to social-auth-app-django==4.0.0 pkg, then get this error:
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: WSGI application 'backend.wsgi.application' could not be loaded; Error importing module.
This error is caused by social_django which is added in settings.py
MIDDLEWARE = [
....
# For social auth
'social_django.middleware.SocialAuthExceptionMiddleware',
....
]
Fixed this error by removing/commenting it out, then found another one:
cannot import name 'urlquote' from 'django.utils.http' (lib\site-packages\django\utils\http.py)
Because urlquote() is no longer available in Django 4.0+ versions, after downgrading social-auth-app-django==4.0.0
pkg.
This try to import from django.utils.http import urlquote in filelib\site-packages\social_django\context_processors.py.
I'm in Dependency hell. I have even tried to downgrading the djoser pkg, then got other errors.
After searching a lot, I found this blog post, according to this:
First, pip install pip-tools then create a requirements.in file and add
django
djangorestframework
then run pip-compile ./requirements.in this will generate requirements.txt file:
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile ./requirements.in
#
asgiref==3.6.0
# via django
django==4.1.5
# via
# -r ./requirements.in
# djangorestframework
djangorestframework==3.14.0
# via -r ./requirements.in
pytz==2022.7.1
# via djangorestframework
sqlparse==0.4.3
# via django
tzdata==2022.7
# via django
But this file doesn't contain other packages like:
django-cors-headers,
djoser,
PyJWT
rest-social-auth
social-auth-app-django,
etc....
Please help me with this question, any resource that can help me.

Related

Error: Django-Social-Auth LinkedIn Client Error

After authentication I got this error message
HTTPError at /oauth/complete/linkedin-oauth2/
410 Client Error: Gone for url: https://api.linkedin.com/v1/people/~:(email-address,first-name,headline,id,industry,last-name)?format=json
Django settings conf
SOCIAL_AUTH_LINKEDIN_OAUTH2_SCOPE = [
'r_emailaddress',
'r_liteprofile'
]
SOCIAL_AUTH_LINKEDIN_OAUTH2_FIELD_SELECTORS = [
'email-address',
'headline',
'industry',]
======================================
Django package versions:
social-auth-app-django==3.1.0
social-auth-core==2.0.0
Django==2.1
For those wondering in May of 2019, the PyPi version is still behind what is in master on Github and is using LinkedIn's deprecated v1 API instead of the v2.
This worked for me:
pip uninstall social-auth-core
pip install git+https://github.com/python-social-auth/social-core

python ConfigParser.NoSectionError: - not working on server

Python 2.7
Django 1.10
settings.ini file(located at "/opts/myproject/settings.ini"):
[settings]
DEBUG: True
SECRET_KEY: '5a88V*GuaQgAZa8W2XgvD%dDogQU9Gcc5juq%ax64kyqmzv2rG'
On my django settings file I have:
import os
from ConfigParser import RawConfigParser
config = RawConfigParser()
config.read('/opts/myproject/settings.ini')
SECRET_KEY = config.get('settings', 'SECRET_KEY')
DEBUG = config.get('settings', 'DEBUG')
The setup works fine locally, but when I deploy to my server I get the following error if I try run any django management commands:
ConfigParser.NoSectionError: No section: 'settings'
If I go into Python shell locally I type in the above imports and read the file I get back:
['/opts/myproject/settings.ini']
On server I get back:
[]
I have tried changing "confif.read()" to "config.readfp()" as suggested on here but it didn't work.
Any help or advice is appreciated.

twisted critical unhandled error on scrapy tutorial

I'm new in programming and I'm trying to learn scrapy, using scrapy tutorial: http://doc.scrapy.org/en/latest/intro/tutorial.html
So I ran "scrapy crawl dmoz" command and got this error:
2015-07-14 16:11:02 [scrapy] INFO: Scrapy 1.0.1 started (bot: tutorial)
2015-07-14 16:11:02 [scrapy] INFO: Optional features available: ssl, http11
2015-07-14 16:11:02 [scrapy] INFO: Overridden settings: {'NEWSPIDER_MODULE': 'tu
torial.spiders', 'SPIDER_MODULES': ['tutorial.spiders'], 'BOT_NAME': 'tutorial'}
2015-07-14 16:11:05 [scrapy] INFO: Enabled extensions: CloseSpider, TelnetConsol
e, LogStats, CoreStats, SpiderState
Unhandled error in Deferred:
2015-07-14 16:11:06 [twisted] CRITICAL: Unhandled error in Deferred:
2015-07-14 16:11:07 [twisted] CRITICAL:
I'm using windows 7 and python 2.7. Anybody knows what's the problem? How could I fix that?
EDIT: My spider file code is:
# This package will contain the spiders of your Scrapy project
#
# Please refer to the documentation for information on how to create and manage
# your spiders.
import scrapy
class DmozSpider(scrapy.Spider):
name = "dmoz"
allowed_domains = ["dmoz.org"]
start_urls = [
"http://www.dmoz.org/computers/programming/languages/python/books/",
"http://www.dmoz.org/computer/programming/languages/python/resources/"
]
def parse(self, response):
filename = response.url.split("/")[-2] + '.html'
with open(filename,'wb') as f:
f.write(response.body)
items.py code:
import scrapy
class DmozItem(scrapy.Item):
title = scrapy.Field()
link = scrapy.Field()
desc = scrapy.Field()
pip list:
bootstrap-admin (0.3.3)
cffi (1.1.2)
characteristic (14.3.0)
cryptography (0.9.3)
cssselect (0.9.1)
Django (1.7.7)
django-auth-ldap (1.2.4)
django-debug-toolbar (1.3.0)
django-mssql (1.6.2)
django-pyodbc (0.2.6)
django-pyodbc-azure (1.2.2)
django-redator (0.2.3)
django-reversion (1.8.5)
django-summernote (0.6.0)
django-windows-tools (0.1.1)
django-wysiwyg-redactor (0.4.3.2)
enum34 (1.0.4)
ez-setup (0.9)
flup (1.0.2)
idna (2.0)
ipaddress (1.0.13)
iso8601 (0.1.4)
logging (0.4.9.6)
lxml (3.4.4)
mechanize (0.2.5)
MySQL-python (1.2.4)
pbr (0.10.8)
Pillow (2.7.0)
pip (7.1.0)
pyasn1 (0.1.8)
pyasn1-modules (0.0.6)
pycparser (2.14)
pymongo (2.6)
pyodbc (3.0.7)
pyOpenSSL (0.15.1)
pypm (1.4.3)
python-ldap (2.4.18)
pythonselect (1.3)
pywin32 (218.3)
queuelib (1.2.2)
Scrapy (1.0.1)
selenium (2.44.0)
service-identity (14.0.0)
setuptools (18.0.1)
six (1.9.0)
sqlparse (0.1.15)
stevedore (1.3.0)
Twisted (15.2.1)
virtualenv (1.11.6)
virtualenv-clone (0.2.5)
virtualenvwrapper (4.3.2)
virtualenvwrapper-powershell (12.7.8)
w3lib (1.11.0)
xlrd (0.9.2)
zope.interface (4.1.2)
Thx for the attention and sry for my poor English, isn't my native language.
I'm beginning to learn scrapy as well and encounter the same question with yours.
After struggling with it for an afternoon, finally I found it's due to the pywin32 module only download without install.
You can try input the command below in the cmd to finish the pywin32 module install and try crawl again:
python python27\scripts\pywin32_postinstall.py -install
I hope it will help!
The short answer is You are missing pywin32!
The other answers are basically right, but not 100% correct. pywin32 is not a pip install! You must download the installer package from here:
http://sourceforge.net/projects/pywin32/files/pywin32/
Make sure that you get the correct bit: 32 or 64. In my case I didn't realize I had the 32bit version of Python installed on my 64bit machine and the installer fails with "Cannot find Python 2.7 installation in registry". I had to install the 32bit version of pywin32. Once I did this, scrapy crawl site worked.
I dont see what your doing with items as your writing to a file. But its the imports maybe. Try this if this does not work try, pip install pywin --update and pip install Twisted --update, that should reinstall any corrupted files.
Plus I dont know if it's Stack's problem but you had some misplaced identation.
from scrapy.spiders import Spider
from {Projectname}.items import {Itemclass}
import scrapy
class DmozSpider(scrapy.Spider):
name = "dmoz"
allowed_domains = ["dmoz.org"]
start_urls = [
"http://www.dmoz.org/computers/programming/languages/python/books/",
"http://www.dmoz.org/computer/programming/languages/python/resources/"]
def parse(self, response):
filename = response.url.split("/")[-2] + '.html'
with open(filename,'wb') as f:
f.write(response.body)
Scrapy crashes with: ImportError: No module named win32api
You need to install pywin32 because of this Twisted bug.

Django ViewDoesNotExist error after installing photologue

I'm using Django 1.5.1. Everything was OK. But as soon as I installed django-photologue through pip I face this error when I visit admin url:
> **ViewDoesNotExist at /admin/**
Could not import django.views.generic.list_detail.object_list. Parent module django.views.generic.list_detail does not exist.
Request Method: GET
Request URL: http://localhost:8000/admin/
Django Version: 1.5.1
Exception Type: ViewDoesNotExist
Exception Value:
Could not import django.views.generic.list_detail.object_list. Parent module django.views.generic.list_detail does not exist.
Exception Location: /usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py in get_callable, line 104
Python Executable: /usr/bin/python
Python Version: 2.7.3
Also when I run syncdb, photologue sync with database without any error and I can import it in shell.
Any idea about how can I solve this error?
to replace the file in the directory urls.py photologue :
"django.views.generic.date_based" and "django.views.generic.list_detail" on "django.views.generic"
"object_list" on "list.ListView"
"object_detail" on "detail.DetailView"
"archive_year" on "dates.YearArchiveView"
"archive_month" on "dates.MonthArchiveView"
"archive_day" on "dates.DayArchiveView"
like this :)
or read :
django-photologue was most likely built for an older version of Django. Looks like the newer version of Django isn't friendly with generic views and prefers class based views instead.
Downloading a fresh copy of Django 1.5.1 shows the following:
http://f.cl.ly/items/0k1J261S2J2f3k3C110I/Image%202013.04.20%203%3A44%3A39%20AM.png
Whereas Django 1.4.2 shows:
http://f.cl.ly/items/152J2U050X0z1j1n0v0D/Image%202013.04.20%203%3A46%3A49%20AM.png
Simply put, the newer version of Django removed the list_detail file.

cannot install django-filebrowser app

I did exactly as it says here: http://readthedocs.org/docs/django-filebrowser/en/latest/quickstart.html#quickstart (only used easy_install instead of pip)
it seems that I get an import error when trying to connect to admin interface:
Request Method: GET
Request URL: http://localhost:8000/admin/
Django Version: 1.3
Exception Type: ImportError
Exception Value:
No module named sites
Exception Location: c:\workspace\expedeat\..\expedeat\urls.py in <module>, line 5
Python Executable: c:\Tools\Python26\python.exe
Python Version: 2.6.4
the import the exception comes from is: from filebrowser.sites import site in urls.py
Also testing filebrowser fails with this message:
Creating test database for alias 'default'...
.......F......
======================================================================
FAIL: test_directory (filebrowser.tests.settings.SettingsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "c:\Tools\Python26\lib\site-packages\django_filebrowser-3.3.0-py2.6.egg\filebrowser\tests\set
tings.py", line 29, in test_directory
self.assertEqual(os.path.exists(os.path.join(MEDIA_ROOT,DIRECTORY)), 1)
AssertionError: False != 1
----------------------------------------------------------------------
Ran 14 tests in 0.008s
FAILED (failures=1)
Destroying test database for alias 'default'...
I must be doing something wrong. Any help would be appreciated.
the sites.py module does not exist in version you are using, so the error message is correct.
the installation doc you are using is for version 3.4. The pip install is 3.3. The difference being in the urls.py
3.4
from filebrowser.sites import site
urlpatterns = patterns('',
url(r'^admin/filebrowser/', include(site.urls)),
)
3.3
urlpatterns = patterns('',
(r'^admin/filebrowser/', include('filebrowser.urls')),
)
The test fails because it's looking for a non-existing directory.
To find out what directory it's looking for, do the following:
% python ./manage.py shell
>>> from django.conf import settings
>>> import filebrowser.settings
>>> filebrowser.settings.MEDIA_ROOT
'/srv/repositories/project/media'
>>> filebrowser.settings.DIRECTORY
'uploads/'
Based on the output, you know what directory it's looking for, /srv/repositories/project/media/uploads in this example. Create the directory and you should be one step further on your way.
Using the "FILEBROWSER_" prefix, you can supply configuration for the filebrowser app.
I use the following in my settings.py :
FILEBROWSER_DIRECTORY = MEDIA_ROOT