I'm trying to install django-import-export.
Python version = 3.6
Django version = 1.10.3
When I entered: pip install django-import-export
It says:
raise ValueError("cannot use LOCALE flag with a str pattern")
ValueError: cannot use LOCALE flag with a str pattern
Thanks in advance.
Related
I have variable site_id = "31.12401" and I want to remove dot.
Here is my code:
try:
cursor = db.tank.find({"site_id": {"$regex": "\."}}).limit(100)
except Exception as e:
print ("exception", type(e), e)
for doc in cursor:
doc["site_id"] = doc["site_id"].replace(".","")
db.tank.save(doc)
It works but I have warning "ipykernel_launcher.py:12: DeprecationWarning: save is deprecated. Use insert_one or replace_one instead"
Anyone can help me?
Try to update monogoengine and pymongo to the latest revision by issuing:
pip3 install -U mongoengine pymongo
Unfortunately, mongoengine update method still yields the deprecation warning propagated from pymongo.
When I run the code below, I get a message saying AttributeError: 'ElementTree' object has no attribute 'itertext'
import xml.etree.cElementTree as ET
url = '[filenamehere].xml'
tree = ET.ElementTree(file=url)
for elem in tree.itertext():
print repr(elem)
It works with just tree.iter() I'm using Python 2.7.3 in Linux Mint Maya. According to the Python documentation, itertext() was added in 2.7, so what am I doing wrong?
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.
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.
I'm trying to update my Django-cms from version 2.2 to 2.3 and when I try to "runserver", I get this error:
django.template.base.TemplateSyntaxError: 'cms_tags' is not a valid tag library: ImportError raised loading cms.templatetags.cms_tags: cannot import name VersionAdapter
The installation of django-cms=2.3 worked perfectly, but there is something somewhere broking everything.
Here's a list of what's installed on this virtualenv:
BeautifulSoup==3.2.0
Django==1.3.1
Fabric==1.4.3
MySQL-python==1.2.3
PIL==1.1.7
South==0.7.3
argparse==1.2.1
cmsplugin-filer==0.8.0
django-admin-tools==0.4.0
-e git://github.com/bmihelac/django-app-name-translation-in- admin.git#c7b033bdfb54fee5217248f4e596aa23752185e0#egg=django_app_name_translation_in_admin-dev
django-appconf==0.4.1
django-classy-tags==0.3.4.1
django-cms==2.3
django-debug-toolbar==0.8.5
django-filer==0.8.5
-e git+https://github.com/toastdriven/django-haystack.git#d2b51143c8008be8523a78822002de1836b9f501#egg=django_haystack-dev
django-hvad==0.1.5
django-mptt==0.5.1
django-page-cms==1.4.5
django-permissions==1.0.3
django-reversion==1.4
django-sekizai==0.5
django-staticfiles==1.1.2
django-transmeta==0.6.2
easy-thumbnails==1.0-alpha-18
feedparser==5.0.1
html5lib==0.90
httplib2==0.7.2
ipython==0.11
poster==0.8.1
pycrypto==2.6
pysolr==2.1.0-beta
python-ptrace==0.6.4
simplejson==2.2.1
sorl-thumbnail==11.09
ssh==1.7.14
virtualenv==1.6.4
wsgiref==0.1.2
Anyone have an idea ?
VersionAdapter belongs to django-reversion so you need need to upgrade (django-reversion) to version 1.6. See the django-cms installation notes:
http://docs.django-cms.org/en/2.3.3/getting_started/installation.html