mod_wsgi + python 2.7.5 import error - python-2.7

I have installed and probably right configurated apache2, mod_wsgi and python 2.7.5. The problem is that 127.0.0.1 is not opening (loading is just freezed) and I see following log in error.log:
[Wed Jun 19 14:49:11 2013] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.4 Python/2.7.3 configured -- resuming normal operations
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site.py", line 548, in <module>
main()
File "/usr/local/lib/python2.7/site.py", line 530, in main
known_paths = addusersitepackages(known_paths)
File "/usr/local/lib/python2.7/site.py", line 266, in addusersitepackages
user_site = getusersitepackages()
File "/usr/local/lib/python2.7/site.py", line 241, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/usr/local/lib/python2.7/site.py", line 231, in getuserbase
USER_BASE = get_config_var('userbase')
File "/usr/local/lib/python2.7/sysconfig.py", line 516, in get_config_var
return get_config_vars().get(name)
File "/usr/local/lib/python2.7/sysconfig.py", line 449, in get_config_vars
import re
File "/usr/local/lib/python2.7/re.py", line 105, in <module>
import sre_compile
File "/usr/local/lib/python2.7/sre_compile.py", line 14, in <module>
import sre_parse
File "/usr/local/lib/python2.7/sre_parse.py", line 17, in <module>
from sre_constants import *
File "/usr/local/lib/python2.7/sre_constants.py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
Tried to restart apache, but it's not working. Thanks for any help!

Just found solution. I checked 'sys.prefix' in my python's interpretator and it printed '/usr/local', but I had not set WSGIPythonHome in apache config (as written in mod_wsgi docs for this case). And just for experiment I set 'WSGIPythonHome /usr'. It's strange, but it resolves my problem, everything is fine now!

Related

Can't launch jupyter Notebook

The screen only shows for about few seconds then disappear without launching anything, Here's what appears on the screen:
Jupyter Notebook (gI-env)
Traceback (most recent call last):
File “C:/Users/user/Anaconda2/envs/gl-env/Scripts/jupyter-notebook-script.py”, line 3, in <module>
import notebook. notebookapp
File “C:\Users\user\Anaconda2\envs\gl-env\lib\site-packages\notebook\notebookapp.py”, line 32, in <module>
from zmq.eventloop import ioloop
File “C:\Python27\Lib\site-packages\zmq\_init_.py’, line 29, in <module>
_load_libzmq()
File “C:\Python27\Lib\site-packages\zmq\_init_.py”, line 21, in _load_libzmq
if platform.python_implementationQ.lower() == ‘pypy’:
File “C:\Python27\Lib\platform.py”, line 1458, in python_implementation
return _sys_versionQ[ø]
File “C:\Python27\Lib\platform.py”, line 1420, in _sys_version
repr(sys_version))
ValueError: failed to parse CPython sys.version: ‘2.7.11 lAnaconda 4.0.0 (64-bit)I (default, Feb 16 2016g 09:58:36) [fISC
v.1500 64 bit (AMD64)]’
What is the error that I'm facing here?

Runtime error when trying to use pip

I have managed to royally screw myself over by doing something which seemed innocuous.
i was getting the following error from my python script (brand['feed'] = the URL i'm making the request to):
**C:\Python27\lib\site-packages\requests\packages\urllib3\util\ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Traceback (most recent call last):
File "D:\Phocas\Phocas-Automation\analytics\download_feed_cats.py", line 18, in <module>
data = requests.get(brand['feed'])
File "C:\Python27\lib\site-packages\requests\api.py", line 69, in get
return request('get', url, params=params, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 594, in send
history = [resp for resp in gen] if allow_redirects else []
File "C:\Python27\lib\site-packages\requests\sessions.py", line 196, in resolve_redirects
**adapter_kwargs
File "C:\Python27\lib\site-packages\requests\sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests\adapters.py", line 431, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: [Errno 1] _ssl.c:507: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed**
So i asked the internet and the internet said do this:
pip install --upgrade ndg-httpsclient
So i did that and now i keep getting a RuntimeError when i run the same script, what's crazy is even if i just try and run pip in the shell, i get the same error!!
Phocas_Tommy#p3303386 MINGW64 /c/Python27
$ pip
Traceback (most recent call last):
File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\pip.exe\__main__.py", line 5, in <module>
File "C:\Python27\lib\site-packages\pip\__init__.py", line 11, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "C:\Python27\lib\site-packages\pip\vcs\mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "C:\Python27\lib\site-packages\pip\download.py", line 22, in <module>
from pip._vendor import requests, six
File "C:\Python27\lib\site-packages\pip\_vendor\requests\__init__.py", line 53, in <module>
from .packages.urllib3.contrib import pyopenssl
File "C:\Python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\contrib\pyopenssl.py", line 43, in <module>
import OpenSSL.SSL
File "C:\Python27\lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "C:\Python27\lib\site-packages\OpenSSL\rand.py", line 12, in <module>
from OpenSSL._util import (
File "C:\Python27\lib\site-packages\OpenSSL\_util.py", line 9, in <module>
binding = Binding()
File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 114, in __init__
self._ensure_ffi_initialized()
File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 126, in _ensure_ffi_initialized
cls._modules,
File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\utils.py", line 31, in load_library_for_binding
lib = ffi.verifier.load_library()
File "C:\Python27\lib\site-packages\cffi\verifier.py", line 96, in load_library
self._compile_module()
File "C:\Python27\lib\site-packages\cryptography\hazmat\bindings\utils.py", line 127, in _compile_module
"Attempted implicit compile of a cffi module. All cffi modules should "
RuntimeError: Attempted implicit compile of a cffi module. All cffi modules should be pre-compiled at installation time.
I have searched this error and can't seem to find anything which helps. I'm using python 2.7.6 on Windows Server 2008 R2 Standard 64-bit
Re-installing Python fixed this problem

Horizon fails to start

I've followed this guide: https://forge.fiware.org/plugins/mediawiki/wiki/fiware/index.php/Identity_Management_-KeyRock-_Installation_and_Administration_Guide
When i run the server i get:
Traceback (most recent call last):
File "manage.py", line 23, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 261, in fetch_command
commands = get_commands()
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 107, in get_commands
apps = settings.INSTALLED_APPS
File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 54, in __getattr__
self._setup(name)
File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 49, in _setup
self._wrapped = Settings(settings_module)
File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 132, in __init__
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'openstack_dashboard.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named oslo.utils
I've tried using --pythonpath but to no avail. I've also ran ./run_tests.sh and here are the results: http://pastebin.com/6i7Ws5Ej.
System:
CentOS 6.5 x64,
python 2.6.6
Any idea how to solve this? any info i might have forgotten don’t hesitate to ask
Edit:
I've switched to ubuntu 12 to follow the tutorial step by step. I got keystone running but horizon still fails and gives me the same error.
A fix was also committed on KeyRock's Github account.
Here is the issue.
Manually updating pbr to 1.3.0 directly from python and pip solved all issues

DJANGO_PATH errors and settings issues

I recently upgraded my Ubuntu to 14.04, and consulted this question to solve my erros, ImportError: No module named _io in ubuntu 14.04. That was solved perfectly.
I also checked out this question as it's similar to mine, Consistently getting ImportError: Could not import settings 'myapp.settings' error, but could not use the same solution.
I do not use manage.py in my project and I have done numerous exports of the PYTHON_PATH to no end of my issues. Here is my traceback;
Traceback (most recent call last):
File "/home/thabang/.virtualenvs/lottostar/bin/django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
commands = get_commands()
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 107, in get_commands
apps = settings.INSTALLED_APPS
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__
self._setup(name)
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/conf/__init__.py", line 49, in _setup
self._wrapped = Settings(settings_module)
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/conf/__init__.py", line 132, in __init__
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'lottostar.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named lottostar.settings
I found the problem:
The was an issue with the egg files during the virtualenv reinstall. Though the programs were there, they couldn't be found. I just performed another install of the requirements to refresh the egg info.

django on ubuntu

I have done everything said on the following page.
https://help.ubuntu.com/community/Django
but it gives me an error page.
MOD_PYTHON ERROR
ProcessId: 2220 Interpreter:
'localhost.localdomain'
ServerName:
'localhost.localdomain' DocumentRoot:
'/etc/apache2/htdocs'
URI: '/' Location:
'/' Directory: None Filename:
'/etc/apache2/htdocs' PathInfo:
'/'
Phase: 'PythonHandler'
Handler:
'django.core.handlers.modpython'
Traceback (most recent call last):
File
"/usr/lib/python2.6/dist-packages/mod_python/importer.py",
line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File
"/usr/lib/python2.6/dist-packages/mod_python/importer.py",
line 1229, in _process_target
result = _execute_target(config, req, object, arg)
File
"/usr/lib/python2.6/dist-packages/mod_python/importer.py",
line 1128, in _execute_target
result = object(arg)
File
"/usr/lib/pymodules/python2.6/django/core/handlers/modpython.py",
line 228, in handler
return ModPythonHandler()(req)
File
"/usr/lib/pymodules/python2.6/django/core/handlers/modpython.py",
line 191, in call
self.load_middleware()
File
"/usr/lib/pymodules/python2.6/django/core/handlers/base.py",
line 33, in load_middleware
for middleware_path in settings.MIDDLEWARE_CLASSES:
File
"/usr/lib/pymodules/python2.6/django/utils/functional.py",
line 276, in getattr
self._setup()
File
"/usr/lib/pymodules/python2.6/django/conf/init.py",
line 40, in _setup
self._wrapped = Settings(settings_module)
File
"/usr/lib/pymodules/python2.6/django/conf/init.py",
line 75, in init
raise ImportError("Could not import settings '%s' (Is it on
sys.path? Does it have syntax
errors?): %s" % (self.SETTINGS_MODULE,
e))
ImportError: Could not import settings
'examples.settings' (Is it on sys.path? Does it have syntax errors?): No module named examples.settings
what could be wrong?
complete noob here.
If you are deploying django project for production under ubuntu server it is recommended to use WSGI. Just fallow the django documentation: https://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/
Installing apache with wsgi under ubuntu is easy:
apt-get install libapache2-mod-wsgi
In case you just want to explore django you do not need to setup apache or anything. Just use manage.py runserver instead.