I"m trying to get web2py running on an Ubuntu machine. All the docs seem to indicate that to run it on a *nix system, you download the source and do:
python web2py.py
I grabbed the source (stable source, not the trunk, version 1.99.4) and tried the above, but after entering a password for the server I get (in the terminal):
$ python web2py.py
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.99.4 (2011-12-14 14:46:14) stable
Database drivers available: google
Starting hardcron...
WARNING:web2py.cron:WEB2PY CRON: Disabled because no file locking
please visit:
http://127.0.0.1:8000
starting browser...
failed to create drawable
DEBUG: connect attempt 0, connection error:
Traceback (most recent call last):
File "/home/aparkin/Downloads/web2py/gluon/dal.py", line 4736, in __init__
self._adapter = ADAPTERS[self._dbname](*args)
File "/home/aparkin/Downloads/web2py/gluon/dal.py", line 1634, in __init__
raise RuntimeError, "Unable to import driver"
RuntimeError: Unable to import driver
WARNING:web2py.cron:WEB2PY CRON: Disabled because no file locking
DEBUG: connect attempt 1, connection error:
Traceback (most recent call last):
File "/home/aparkin/Downloads/web2py/gluon/dal.py", line 4736, in __init__
self._adapter = ADAPTERS[self._dbname](*args)
File "/home/aparkin/Downloads/web2py/gluon/dal.py", line 1634, in __init__
raise RuntimeError, "Unable to import driver"
RuntimeError: Unable to import driver
DEBUG: connect attempt 2, connection error:
Traceback (most recent call last):
File "/home/aparkin/Downloads/web2py/gluon/dal.py", line 4736, in __init__
self._adapter = ADAPTERS[self._dbname](*args)
File "/home/aparkin/Downloads/web2py/gluon/dal.py", line 1634, in __init__
raise RuntimeError, "Unable to import driver"
RuntimeError: Unable to import driver
DEBUG: connect attempt 3, connection error:
Traceback (most recent call last):
File "/home/aparkin/Downloads/web2py/gluon/dal.py", line 4736, in __init__
self._adapter = ADAPTERS[self._dbname](*args)
File "/home/aparkin/Downloads/web2py/gluon/dal.py", line 1634, in __init__
raise RuntimeError, "Unable to import driver"
RuntimeError: Unable to import driver
DEBUG: connect attempt 4, connection error:
Traceback (most recent call last):
File "/home/aparkin/Downloads/web2py/gluon/dal.py", line 4736, in __init__
self._adapter = ADAPTERS[self._dbname](*args)
File "/home/aparkin/Downloads/web2py/gluon/dal.py", line 1634, in __init__
raise RuntimeError, "Unable to import driver"
RuntimeError: Unable to import driver
And then in the browser I get:
Internal error
Ticket issued: welcome/127.0.0.1.2012-.....[abbreviated]
Any suggestions? I'm running Python 2.7.1+. I've read elsewhere that you also need pyschopg2 installed for web2py to run, and I've confirmed that this is in fact installed as well (I did a sudo apt-get install python-psycopg2 and got "python-psycopg2 is already the newest version").
I just downloaded and web2py runs ok in ubuntu, python 2.7.2+
bruce#vaiubuntu:~/Downloads/web2py$ python web2py.py
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2011
Version 1.99.4 (2011-12-14 14:46:14) stable
Database drivers available: SQLite3, pymysql, PostgreSQL
Starting hardcron...
Are you trying to run web2py on appengine environment?
Do you have SQLITE module working ok in your Python?
A possibility is permission issue, your user have permission to write to web2py/* folder?
It looks like a bug in web2py 1.99.4. I was having the same problem using Postgres and psycopg2, but in Windows.
I tried with 1.99.2 and it worked fine.
Actually, the bug seems to be related to the cryptic error message - 1.99.2 gave me the error message that the database doesn't exist, which was easily fixed. 1.99.4 does not mention the missing database. However, when I created the database and tried with 1.99.4, it worked fine.
Related
On an ubuntu system I am trying to use a 'browsernmob-proxy' with python-selenium tests. Following the documentation here I installed 'browsermob-proxy' and I tried the following python code:
from selenium import webdriver
from browsermobproxy import Server
server = Server("/home/adietz/Projects/Venv/nosetests/lib/python2.7/site-packages/browsermobproxy/server.py")
server.start()
but this immediately failed with the following error:
======================================================================
ERROR: test_example2.TestSuite.test_network
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/adietz/Projects/Venv/nosetests/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/adietz/Projects/Jenkins/bsp-usecase-tests/selenium/test_example2.py", line 41, in test_network
server.start()
File "/home/adietz/Projects/Venv/nosetests/local/lib/python2.7/site-packages/browsermobproxy/server.py", line 113, in start
stderr=subprocess.STDOUT)
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
Any idea how to fix this?
I also tried to use
server = Server("/home/adietz/Projects/Venv/nosetests/lib/python2.7/site-packages/browsermobproxy")
instead, but this failed with the following error:
======================================================================
ERROR: test_example2.TestSuite.test_network
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/adietz/Projects/Venv/nosetests/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/adietz/Projects/Jenkins/bsp-usecase-tests/selenium/test_example2.py", line 40, in test_network
server = Server("/home/adietz/Projects/Venv/nosetests/lib/python2.7/site-packages/browsermobproxy")
File "/home/adietz/Projects/Venv/nosetests/local/lib/python2.7/site-packages/browsermobproxy/server.py", line 81, in __init__
"in path provided: %s" % path)
ProxyServerError: Browsermob-Proxy binary couldn't be found in path provided: /home/adietz/Projects/Venv/nosetests/lib/python2.7/site-packages/browsermobproxy
Addendum
I probably managed to get the browsermob-proxy to tun at port 8088 or 8089 (not exactly sure), but the example code still won't run ....
I guess, you are giving wrong path for the proxy server. Your code is pointing to the browsermob proxy python bindings instead of the server. Please follow the below steps.
Download the browsermob proxy from the location https://github.com/lightbody/browsermob-proxy/releases and unzip the file to particular directory. I have extracted/unzipped to directory C:\\Projects\\BrowserMobProxy
Install the browsermob proxy bindings if not already installed.
pip install browsermob-proxy
Then you can point the server path in the coding as follows. I am using windows. as given below.
from browsermobproxy import Server
server = Server("C:\\Projects\\BrowserMobProxy\\bin\\browsermob-proxy")
server.start()
proxy = server.create_proxy()
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_proxy(proxy.selenium_proxy())
driver = webdriver.Firefox(firefox_profile=profile)
proxy.new_har("google")
driver.get("http://www.google.co.uk")
proxy.har # returns a HAR JSON blob
server.stop()
driver.quit()
Please change the proxy path accordingly(where you have downloaded or extracted).
I want to link my Python packages to my Access database, but I get this error. I use python 2.7.12 (shell).
import pypyodbc
#create connection
con = pypyodbc.connect('DRIVER={Microsoft Access-Treiber (*.mdb)};UID=admin;UserCommitSync=Yes;Threads=3;SafeTransactions=0;PageTimeout=5;MaxScanRows=8;MaxBufferSize=2048;FIL={MS Access};DriverId=25;DefaultDir=//Users/123GuteLaune/DatabaseMAformat.mdb')
cursor = con.cursor()
#Select Data
cursor.execute("SELECT * from TW-DS")
for row in cursor.fetchone():
print(row)}
Traceback (most recent call last):
File "", line 1, in
import pypyodbc
ImportError: No module named pypyodbc
Edit
Hi after second installation following error occurs
Traceback (most recent call last): File "/Users/123GuteLaune/Python/connectionprogramm.py", line 4, in con = pypyodbc.connect('DRIVER={Microsoft Access-Treiber (*.mdb)};UID=admin;UserCommitSync=Yes;Threads=3;SafeTransactions=0;PageTimeout=5;MaxScanRows=8;MaxBufferSize=2048;FIL={MS Access};DriverId=25;DefaultDir=//Users/123GuteLaune/DatabaseMAformat.mdb') File "build/bdist.macosx-10.6-intel/egg/pypyodbc.py", line 2435, in init self.connect(connectString, autocommit, ansi, timeout, unicode_results, readonly) File "build/bdist.macosx-10.6-intel/egg/pypyodbc.py", line 2484, in connect check_success(self, ret) File "build/bdist.macosx-10.6-intel/egg/pypyodbc.py", line 989, in check_success ctrl_err(SQL_HANDLE_DBC, ODBC_obj.dbc_h, ret, ODBC_obj.ansi) File "build/bdist.macosx-10.6-intel/egg/pypyodbc.py", line 976, in ctrl_err err_list.append((from_buffer_u(state), from_buffer_u(Message), NativeError.value)) File "build/bdist.macosx-10.6-intel/egg/pypyodbc.py", line 483, in UCS_dec uchar = buffer.raw[i:i + ucs_length].decode(odbc_decoding) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/utf_32.py", line 11, in decode return codecs.utf_32_decode(input, errors, True) UnicodeDecodeError: 'utf32' codec can't decode bytes in position 0-1: truncated data
Edit on 12.10.2016
I use a Mac with macOS El Captain. I have the program "Parallels" on my laptop for using Access in a virtual machine. Python is installed on the Mac side.
What must I change that Python can use the ODBC interface to Access?
Edit 13.10.2016
I find a the toolkit "pyodbc" i think this should work on mac but again i can not ran the setup file i got the error. I already installed homebrew and find this dokumentation for installing (https://github.com/lionheart/django-pyodbc/wiki/Mac-setup-to-connect-to-a-MS-SQL-Server)
Error in python:
Traceback (most recent call last):
File "/Users/123GuteLaune/connectionprogramm.py", line 1, in
import pyodbc
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyodbc.so, 2): Library not loaded: /usr/local/lib/libodbc.2.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyodbc.so
Reason: image not found
If you are running Python on the Mac side then you need to use a driver that is compatible with macOS. The Microsoft Access-Trebier (*.mdb) ODBC driver is a Windows DLL (ODBCJT32.DLL) and I doubt very much that the Mac version of Python can use it.
You may be interested in the related question here:
Read an Access database in Python on non-Windows platform (Linux or Mac)
I am using python to open a hid/hidapi (the error is the same either way) connection on OSX El Capitan. However, It gives me the following error stacktrace:
Traceback (most recent call last):
File "/Users/johndoe/Library/Python/2.7/lib/python/site-packages/gevent/greenlet.py", line 534, in run
result = self._run(*self.args, **self.kwargs)
File "/Users/johndoe/IdeaProjects/projectname/emokit-master/python/emokit/emotiv.py", line 403, in setup
self.setup_darwin()
File "/Users/johndoe/IdeaProjects/projectname/emokit-master/python/emokit/emotiv.py", line 526, in setup_darwin
data = hidraw.read(34)
File "hid.pyx", line 105, in hid.device.read (hid.c:2338)
ValueError: not open
<Greenlet at 0x10f7f1b90: <bound method Emotiv.setup of <emokit.emotiv.Emotiv object at 0x10f532c50>>> failed with ValueError
I can't find anything on this, and do not usually use OSX or python, so I am at a bit of a loss
Often, hidapi needs sudo permissions on a mac for some reason. Even if you are running Ubuntu on a mac.
Not sure what the issue is. Works fine via ssh. When viewed in a browser I get a server error. This is know working code that has been migrated to another server / environment.
It can not find a module that is clearly in the directory. Have checked permissions on files and they look ok 755.
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator to inform of the time the error occurred and of anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
ImportError: No module named xmlproducts
mod_python (pid=16232, interpreter='realtechy.com', phase='PythonHandler', handler='mod_python.cgihandler'): Application error
ServerName: 'realtechy.com'
DocumentRoot: '/var/www/vhosts/realtechy.com/httpdocs'
URI: '/products/myproducts.py'
Location: None
Directory: '/var/www/vhosts/realtechy.com/httpdocs/'
Filename: '/var/www/vhosts/realtechy.com/httpdocs/products/myproducts.py'
PathInfo: ''
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch\n default=default_handler, arg=req, silent=hlist.silent)
File "/usr/lib/python2.6/site-packages/mod_python/importer.py", line 1229, in _process_target\n result = _execute_target(config, req, object, arg)
File "/usr/lib/python2.6/site-packages/mod_python/importer.py", line 1128, in _execute_target\n result = object(arg)
File "/usr/lib/python2.6/site-packages/mod_python/cgihandler.py", line 96, in handler\n imp.load_module(module_name, fd, path, desc)
File "/var/www/vhosts/realtechy.com/httpdocs/products/myproducts.py", line 6, in <module>\n import xmlproducts
ImportError: No module named xmlproducts
Sounds like the module is not installed properly (or at all). To verify, do the following:
open a shell and start the python shell by typing python
enter the commmand help('modules')
review the list of modules that's returned to see whether xmlproducts is included
if not, then install the module
I just installed pymongo from an .exe on a windows 7 box. I tried connecting to mongodb by:
import pymongo
c = pymongo.Connection()
i get the following error:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
c = pymongo.Connection()
File "E:\Softwares\installed\Python2.7\lib\site-packages\pymongo\connection.py", line 370, in __init__
self.__find_master()
File "E:\Softwares\installed\Python2.7\lib\site-packages\pymongo\connection.py", line 605, in __find_master
raise AutoReconnect("could not find master/primary")
AutoReconnect: could not find master/primary
I did some googling and i figured that the mongodb daemon is not running and hence i'm not able to connect. I tried doing the following:
c = pymongo.Connection('localhost', 27017)
But i got the same error. How do i start the mongodb deamon ?? Or is there any other problem/error ??
Thanks in advance :)
Go to http://www.mongodb.org/downloads to download the version of mongodb for your operating system.
Unzip the downloaded folder.
Run the file mongod.exe. (This is in the "bin" folder)
You should now be able to connect using pymongo.