Django mod-python error - python

Can someone please tell what this strange error is
Mod_python error: "PythonHandler django.core.handlers.modpython"
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 287, in HandlerDispatch
log=debug)
File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 464, in import_module
module = imp.load_module(mname, f, p, d)
File "/project/django/django/core/handlers/modpython.py", line 4, in ?
from django import http
File "/project/django/django/http/__init__.py", line 3, in ?
from Cookie import SimpleCookie, CookieError
ImportError: No module named Cookie
Edit:
Python
Python 2.4.3 (#1, Jan 14 2008, 18:32:40)
[GCC 4.1.2 20070626 (Red Hat 4.1.2-14)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from Cookie import SimpleCookie, CookieError
>>> from http.Cookie import SimpleCookie, CookieError
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named http.Cookie
>>> import Cookie
>>> import http.Cookie
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named http.Cookie
>>> import http.Cookie

That you're missing the Cookie package (which is not part of Django), but it should be Builtin.
If you're using Python 3 please note that Cookie has been renamed to http.cookies, and that Django is incompatible with Python not 2.x.
That is what you're missing: http://docs.python.org/library/cookie.html.
Edit
I see you're running python 2.4. Consider switch to python 2.6 or 2.7, and check the presence of /usr/lib/python2.4/Cookie.py
Solution
The path was missing, so adding
sys.path.append('/usr/lib/python2.4/')
solves the issue.

Related

Unable to import beautifulsoup4 module in Termux

Here's the full log which shown that I'm unable to import beautifulsoup4
$ python
Python 3.7.5 (default, Oct 23 2019, 08:30:10)
[Clang 8.0.7 (https://android.googlesource.com/toolchain/clang b55f2d4ebfd35bf6 on linux
Type "help", "copyright", "credits" or "license" for more information.
import bs4
from bs4 import beautifulsoup4
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'beautifulsoup4' from 'bs4' (/data/data/com.termux/files/usr/lib/python3.7/site-packages/bs4/__init__.py)
import beautifulsoup4
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'beautifulsoup4'
This works for me:
>>> from bs4 import BeautifulSoup
>>>

ete3 module on python3 - cannot import TreeStyle, faces, AttrFace, NodeStyle

I a linux user and so far I've using ete3 in python2 succesfully.
I installed ete3 for python3 and there are certain modules that python3 can't find. I believe I have all the dependencies installed according to the instructions.
I can import ete3, and Tree from ete3 but not any other that I've using so far.
Any clues on how to resolve this?
~$ python3
Python 3.4.3 (default, Nov 28 2017, 16:41:13)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ete3
>>> from ete3 import Tree
>>> from ete3 import TreeStyle
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'TreeStyle'
>>> from ete3 import faces
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'faces'
>>> from ete3 import AttrFace
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'AttrFace'
>>> from ete3 import NodeStyle
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'NodeStyle'
I managed to install the dependencies. The problem was that ete3 is not reporting properly the missing dependencies.
You can see which dependencies are missing with this code:
import ete3
ete3.__file__
I run it multiple times and install the packages that was complaining about each time until it finally worked!

Python DLL import error when importing vtk

I need to use the VTK library (with version 5.10 because I am working on an existing code) in python on my Windows 10 machine but I can not manage to import it without DLLImport error:
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import vtk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\vtk\__init__.py", line 139, in <module>
__helper.refine_import_err('qvtk', 'vtkQtPython', exc)
File "C:\Python27\lib\site-packages\vtk\__helper.py", line 32, in refine_import_err
raise LinkError, str(exc)
vtk.__helper.LinkError: DLL load failed: The specified module could not be found.
I have installed PyQt4 4.11.4 and VTK 5.10.1 in 32 bits version (my Python 2.7.12 installation is 32 bits too), downloaded here: http://www.lfd.uci.edu/~gohlke/pythonlibs/
I think the issue is related to the vtkQtPython pyd and dll (the files are vtkQtPython.pyd which tries to load vtkQtPythonD.dll:
>>> import qvtk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "qvtk.py", line 5, in <module>
from vtkQtPython import *
ImportError: DLL load failed: The specified module could not be found.
>>> import vtkQtPython
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
Importing vtk using the latest version (7.0.0) does work, but is not compatible with the code I am working on. I have already tried uninstalling and set-up the whole installation again (all libraries and Python itself).
I hope you'll find some ideas, I still could not find any solution after hours struggling.

Can't import appengine python module

On my local machine I am unable to import appengine.ext module.
I have set the path using the following code
>>> import sys
>>> sys.path.insert(1, '/usr/local/google_appengine')
>>> sys.path.insert(1, '/usr/local/google_appengine/lib/yaml/lib')
Here is the error
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.insert(1, '/usr/local/google_appengine')
>>> sys.path.insert(1, '/usr/local/google_appengine/lib/yaml/lib')
>>> from google import appengine
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name appengine
>>> from google.appengine.ext import ndb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named appengine.ext
>>>
you should try to add the following code to the begining:
import dev_appserver
dev_appserver.fix_sys_path()
should work :).

Python Import Error when importing tests from django-social-auth

I'm trying to subclass some classes from the django-social-auth package to create custom test.
The source https://github.com/omab/django-social-auth
The problem is that i cannot import the "tests" part:
C:\Users\Alle>python
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import social_auth.tests.base
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tests.base
>>> import social_auth.tests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tests
>>> import social_auth.db
>>> social_auth.db
<module 'social_auth.db' from 'C:\Python26\lib\site-packages\social_auth\db\__init__.pyc'>
>>>
why i get this behaviour?
Tests aren't installed by default
from social_auth setup.py
packages=['social_auth',
'social_auth.management',
'social_auth.management.commands',
'social_auth.backends',
'social_auth.backends.contrib',
'social_auth.backends.pipeline',
'social_auth.migrations',
'social_auth.db'],

Categories