Am having a real problem with the geodjango saving an entry.
It produces a "Error: Access Violation reading 0x???????"
The error does not indicate which file or folder it's trying to gain read/write access to.
Upon researching i found other non-django programs that also have this issue, some were fixed by turning off Vista's DEP controller, but am a bit scared to go down this route and am not even totally sure if this would fix the issue.
Any one got any ideas....?
Vista is a nightmare to work on.
Below is error output:
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310
Type "help", "copyright", "credits" or "license" for more in
(InteractiveConsole)
from django.contrib.gis.utils import add_postgis_srs
add_postgis_srs(900913)
from geofencing.models import FencingBorder
from django.contrib.gis.geos import Point
il = FencingBorder()
il.name = 'some place'
il.interestingness = 3
il.geometry = Point(-16.57,14.0)
Traceback (most recent call last):
File "", line 1, in
File "C:\SWsoft\Plesk\Additional\Python\lib\site-packages\
if isinstance(value, self._klass) and (str(value.geom_ty
File "C:\SWsoft\Plesk\Additional\Python\Lib\site-packages\
return capi.geos_type(self.ptr)
File "C:\SWsoft\Plesk\Additional\Python\lib\site-packages\
in call
return self.cfunc(*args)
File "C:\SWsoft\Plesk\Additional\Python\lib\site-packages\
check_string
free(result)
WindowsError: exception: access violation reading 0x03C2A964
il.geometry = Point(-16.57,14.0)
Traceback (most recent call last):
File "", line 1, in
File "C:\SWsoft\Plesk\Additional\Python\lib\site-packages\
if isinstance(value, self._klass) and (str(value.geom_ty
File "C:\SWsoft\Plesk\Additional\Python\Lib\site-packages\
return capi.geos_type(self.ptr)
File "C:\SWsoft\Plesk\Additional\Python\lib\site-packages\
in call
return self.cfunc(*args)
File "C:\SWsoft\Plesk\Additional\Python\lib\site-packages\
check_string
free(result)
WindowsError: exception: access violation reading 0x03C2A964
Right
In case anyone else ever has the issue..
The problem was following a doc referenced at:
http://code.google.com/p/geodjango-basic-apps/wiki/FOSS4GWorkshop
if you install GDAL from binary or install PostgreSQL 9.0
DO NOT reference the GDAL dll file in your settings.py.
Always go with setting the VARIABLE_DEFINITION in windows system's PATH.
The culprit was this in settings.py:
GEOS_LIBRARY_PATH='c:\geodjango\gdal\bin\geos_c_fw.dll'
You seems to have answered your own question. Thanks for the suggestion. I had a similar issue as well. I also had a line like:
GEOS_LIBRARY_PATH = r'C:\OSGeo4W\bin\geos_c.dll'
(Hijack the topic for a while. I know people have problems with finding a working geos binary distribution on windows. After several tries, seems OSGeo4W's distribution works for me. But I read on other people's blogs that some other distribution instead of OSGeo4W's works on their machines.)
So I remove this line and add C:\OSGeo4W\bin\geos_c.dll to system's PATH environment variable. After that, it works fine. So this confirms Tuscan's solution. Hopes it can help people running into the same issue.
Related
Running the latest Django (3.0.4) I am now getting this:
File "[...]site-packages/django/contrib/gis/gdal/driver.py", line 5, in <module>
from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
File "[...]site-packages/django/contrib/gis/gdal/prototypes/ds.py", line 71, in <module>
get_field_as_integer64 = int64_output(lgdal.OGR_F_GetFieldAsInteger64, [c_void_p, c_int])
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ctypes/__init__.py", line 361, in __getattr__
func = self.__getitem__(name)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ctypes/__init__.py", line 366, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(0x101667060, OGR_F_GetFieldAsInteger64): symbol not found
My Observations:
I have [ellided] the path names which refer to Django in my virtual-environment. I observe that the module that is actually crashing is in /Library/Frameworks/Python.framework/ ... this on Macintosh OS/X Catalina.
The version of Python that is installed on this computer is 3.6.4. (The version on the hosting service is considerably older ... 3.4.)
Is this, as I suspect, a problem with the Python installation on this computer? (The most recent version that can be installed here is 3.7.7.)
EDIT: NO, it isn't!
After installing Django 3.0.4 on a Linux host I got this:
AttributeError: /usr/local/lib/libgdal.so.1: undefined symbol: OGR_F_GetFieldAsInteger64
Now, once again this is a system-wide library that's being called, but I now suspect that the root cause problem is actually in this line:
File "[...]/lib/python3.6/site-packages/django/contrib/gis/gdal/prototypes/ds.py", line 71, in <module>
get_field_as_integer64 = int64_output(lgdal.OGR_F_GetFieldAsInteger64, [c_void_p, c_int])
I am now rolling Django versions backward to see if I can make the problem go away and if so "answer my own question."
I had to walk back all the way to Django 2.1 before the problem finally went away.
libgdal version 1.6 is installed on this computer's virtual-environment and I don't know if it is practical nor possible for me to change it. ("gcc" is installed here, "configure" is not.)
I am currently using Python 2.7 and my OS is Windows 7. While attempting to use the Bloomberg API I am getting this error:
Traceback (most recent call last):
File "datagrab.py", line 1, in <module>
import blpapi, time, json
File "C:\Python27\lib\blpapi\__init__.py", line 5, in <module>
from .internals import CorrelationId
File "C:\Python27\lib\blpapi\internals.py", line 50, in <module>
_internals = swig_import_helper()
File "C:\Python27\lib\blpapi\internals.py", line 42, in swig_import_helper
import _internals
ImportError: No module named _internals
I have set my path variable to point to blpapi3_64.dll and also updated my bloomberg terminal. I have also moved the local blpapi API to a different directory but still the problem exists.
I am kind of new to this API in general. So can someone please guide me?
Thank you in advance!
From your question is sounds like maybe you have tried this, but just outlining one possible solution from the README in the Python Supported Release release available here.
Note that many Python installations add the current directory to the
module search path. If the Python interpreter is invoked from the
installer directory, such a configuration will attempt to use the
(incomplete) local blpapi directory as a module. If the above
import line fails with the message Import Error: No module named
_internals, move to a different directory before invoking python.
I know this question is a bit stale, but in case people end up here like me. Do you have the C++ version of blpapi? it is a requirement for the python api as mentioned here: https://www.bloomberg.com/professional/support/api-library/
so download the C++ zip installer, extract somewhere, and then add it as an environment variable so that the python api can find it:
Environment variable name: BLPAPI_ROOT
Value: C:\blp\blpapi_cpp_3.8.18.1 (THIS IS WHERE MINE IS INSTALLED, YOUR VALUE HERE MAY BE DIFFERENT)
Hope that helps!
I have put down a Django project I was working on for a couple months, when I attempted to re run the server I got this error:
ValueError: source code string cannot contain null bytes
The Traceback is:
C:\Users\Broja\Desktop\mynewenv\computersite>manage.py runserver
Traceback (most recent call last):
File "C:\Users\Broja\Desktop\mynewenv\computersite\manage.py", line 8, in
<module>
from django.core.management import execute_from_command_line
File "C:\Users\Broja\AppData\Local\Programs\Python\Python35\lib\site-
packages\django\__init__.py", line 3, in <module>
from django.utils.version import get_version
ValueError: source code string cannot contain null bytes
I am not too familiar with the Django Framework so this error confuses me, any help would go a long way. Thanks.
Just convert it to UTF-8. That worked for me :)
Anyone who is looking for a simple solution in windows OS.
Just edit the target file(the file which is causing the issue) in Notepad.
Click File.
Click Save As.
Along the Save Button, there is an option for Encoding, just select
UTF-8 and select All Files option from the Save As Type option and
enjoy
I am installing spark 1.2.1 on windows 8 and I have downloaded a prebuilt package for Hadoop 2.4
When i am running pyspark i am getting the following error:
C:\Users\Dinesh\Desktop\spark-1.2.1-bin-hadoop2.4>bin\pyspark
Running python with PYTHONPATH=C:\Users\Dinesh\Desktop\spark-1.2.1-bin-hadoop2.4\bin\..\python\lib\py4j-0.8.2.1-src.zip;C:\Users\Dinesh\Desktop\spark-1.2.1-bin-hadoop2.4\bin\..\python;
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
The system cannot find the path specified.
Traceback (most recent call last):
File "C:\Users\Dinesh\Desktop\spark-1.2.1-bin-Hadoop2.4\bin\..\python\pyspark\shell.py", line 45, in <module>
sc = SparkContext(appName="PySparkShell", pyFiles=add_files)
File "C:\Users\Dinesh\Desktop\spark-1.2.1-bin-hadoop2.4\python\pyspark\context.py", line 102, in __init__
SparkContext._ensure_initialized(self, gateway=gateway)
File "C:\Users\Dinesh\Desktop\spark-1.2.1-bin-hadoop2.4\python\pyspark\context.py", line 212, in _ensure_initialized
SparkContext._gateway = gateway or launch_gateway()
File "C:\Users\Dinesh\Desktop\spark-1.2.1-bin-hadoop2.4\python\pyspark\java_gateway.py", line 73, in launch_gateway
raise Exception(error_msg)
Exception: Launching GatewayServer failed with exit code 1!
Warning: Expected GatewayServer to output a port, but found no output.
I have searched and i got that in general the error is caused as the path variable are not correctly defined,but i have checked and my variable are all in place. How can i solve the error?
"The system cannot find the path specified." Which path is it talking about.?
In my case the problem came from the terminal I was using. On Git Bash on Windows I was getting the error : line 96: CMD: bad array subscript when executing spark-shell, but when I tried on PowerShell it worked fine.
The way I debugged this issue was to rem the "#echo off" command on all the command files that got called by pyspark.cmd.
In the end I nailed it down to me having JAVA_HOME set to "C:\ProgramData\Oracle\Java\javapath" which is wrong as one of the cmd scripts adds a "\bin" to JAVA_HOME before calling java.exe and it was triggering the "The system cannot find the path specified." error.
So I changed JAVA_HOME to "C:\Program Files\Java\jdk1.8.0_25" and it worked fine.
Now I have to un-rem the "#echo off"s. Hope it helps!
It maybe caused by cygwin in the DOS classpath. Spark uses the find command in the file 'spark-class2.cmd', which used then the cygwin find command instead of the DOS find command, which works somewhat different. I removed cygwin from the DOS PATH, which solved the problem.
I've recently upgraded my project environment to django 1.6. After the upgrade, I found out that all the static files in the existing projects do not work anymore, even if I create a new project following the tutorial, the static file still does not work. Can any one help me out?
Here is my project structure
-mysite
manage.py
-mysite
urls.py
views.py
settings.py
__init__.py
wsgi.py
-static
jqury.js
settings.py looks like this
INSTALLED_APPS = (
...
'django.contrib.staticfiles',
)
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'WorldCup\\templates'),
)
TEMPLATE_CONTEXT_PROCESSORS = [
'django.core.context_processors.static',
'django.contrib.auth.context_processors.auth',
]
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'WorldCup\\static'),
)
print STATICFILES_DIRS
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
I print the staticfiles_dirs, the result is ('G:\django_project\mysite\mysite\static',), which correctly points to my static file folder.
The html file looks like:
{% load staticfiles %}
<script type="text/javascript" src="{% static "WorldCup/jquery-1.10.2.js" %}"
<body>
hello world======{% static "WorldCup/jquery-1.10.2.js" %}=======
</body>
the page displays "hello world======/static/jquery-1.10.2.js=======", which seems correct.
But the Console complained with:
Traceback (most recent call last):
File "D:\Python27\lib\wsgiref\handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "D:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 68, in __call__
return super(StaticFilesHandler, self).__call__(environ, start_response)
File "D:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 206, i
n __call__
response = self.get_response(request)
File "D:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 58, in get_response
return self.serve(request)
File "D:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 51, in serve
return serve(request, self.file_path(request.path), insecure=True)
File "D:\Python27\lib\site-packages\django\contrib\staticfiles\views.py", line
41, in serve
return static.serve(request, path, document_root=document_root, **kwargs)
File "D:\Python27\lib\site-packages\django\views\static.py", line 61, in serve
content_type, encoding = mimetypes.guess_type(fullpath)
File "D:\Python27\lib\mimetypes.py", line 297, in guess_type
init()
File "D:\Python27\lib\mimetypes.py", line 358, in init
db.read_windows_registry()
File "D:\Python27\lib\mimetypes.py", line 258, in read_windows_registry
for subkeyname in enum_types(hkcr):
File "D:\Python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb9 in position 0: ordinal
not in range(128)
[01/Dec/2013 07:42:33] "GET /static/jquery-1.10.2.js HTTP/1.1" 500 59
Even if I change to the image file instead of js file, I still get those errors....
My best guess based on your error message is that you have non-ASCII characters in your Windows registry, and something in the mimetypes module (part of the Python standard library) is choking on that. I assume either the Django statics server, or the Django staticfiles app itself, is calling mimetypes.
This is not a problem with your system per se; if I'm correct in my diagnosis it's clearly a bug in mimetypes.
Here are some options:
You could upgrade to Python 3.3 or 3.4 beta. Django 1.6 is fully compatible with Python 3 and I would be very surprised to see that this bug still exists in Py3 because one of the explicit goals of Py3 was to make unicode encode/decode errors less common.
You could downgrade back to Django 1.5.
You could use a different operating system for development work. Relatively few Python programmers do their dev work in Windows, although the number is not zero either. You are less likely to run into extremely obscure bugs if you use OS X or Linux for development work. That having been said, Windows is an officially supported platform, so if there is a problem with the interaction between CPython and Windows, then that is a CPython bug.
You could try to find exactly what change between 1.5 and 1.6 caused this problem, but that is likely a fool's errand and, assuming it's not an outright bug in Django, will at best result in you having to maintain a fork with your patch for your personal use (not recommended).
You could try to find the offending line in your registry and scrub it, but I don't know how you would go about doing this. You may have a combination of locale settings, the localized version of Windows, non-English installed software or custom MIME types that is causing this problem. Since it seems likely that it is a bug in the mimetypes library and not the fault of your system, you could easily find that the problems in your registry are simply a consequence of some normal function of your computer.
If the problem is with the Django statics server in a way that wouldn't affect your application in production (where the Django statics server, which is only suitable for development, would presumably be disabled) then you could disable the Django statics server and use some other statics serving solution for development. This is inconvenient but would probably work, as long as the problem is with the Django statics server only. To test, set DEBUG to False or otherwise turn off the statics server and run your application -- if it still crashes, then it's not a Django statics server issue; otherwise, it likely is.
Finally, you could try to track down the actual bug and fix it. This is a complex process -- you would need to isolate the bug, see whether it needs to be fixed in the CPython standard library or in Django (I suspect the former), file a report with either of those projects, then write a patch and submit it or get someone else to do likewise. Until it is submitted and accepted, you could theoretically maintain a fork of CPython with the fix applied, but that is a maintenance nightmare.
There is still the possibility that I am outright wrong about the cause and it's not a bug in mimetypes -- in that case you might have more options.
very unfortunetly I have this problem as well. I was using python 3.3, everything works fine. But since my production side is running python 2.7, so I created an a virtualenv with python 2.7.6, and then installed South, debug toolbar, which is the same as my Python3.3 environment. But it just simply not work with python2.7 virtualenv. My Django version is 1.6. So my simple way around this is to switch back to my python3.3.
For more details, my guess would be something related models/database goes wrong. I recall that after a database migration in my virtualenv python2.7 version, this problem appears, while before that everything goes well.
So I would suggest you to run a virtualenv with Python3.3, and debug for the old problem whenever you have more time. Anyway, to save time first. I find Django is really a nice framework, but Python with its multiple packages just have too much buggy stuff that you just do not want to waste your time to go over every one of them.
I have same problem.
Today I have access only to machine, with windows XP.
I've debugged this error and found, that key in windows registry has bad value.
In my case it was: 'BDATuner.���������'.
I hadn't enouth time to edit registry so I temporary add exception to File "D:\Python27\lib\mimetypes.py", line 249, in enum_types
try:
ctype = ctype.encode(default_encoding) # omit in 3.x!
except UnicodeEncodeError, UnicodeDecodeError:
pass
else:
yield ctype
I solved my problems.
I know that patching django code that way is bad, so it's only workaround.
The correct way is to get rid of bad registry values (regedit - next search for this values).