i install a web2py on my machine. i simply click on web2py.exe then it asking for password then it says "unable to detect your browser".
Any help will be appreciable.
This is not an error, it is just a warning message.
This message is being introduced by this line which propose is just to open the web browser automatically.
But, even without webbrowser module you should be able to run web2py and ignore the warning message,
If you are unable to run web2py or having any trouble, please open an issue ticket and web2py developers will look in to it.
The message is coming from here:
def try_start_browser(url):
""" Try to start the default browser """
try:
import webbrowser
webbrowser.open(url)
except:
print 'warning: unable to detect your browser'
You might try the webbrowser.open from a python cli shell to see what the specific exception is. On my (OS X) system:
~ $ python
Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import webbrowser
>>> webbrowser.open('http://stackoverflow.com')
True
Related
I would like to write an application, which shall clone a virtual machine from virtualBox, which I installed separetly. I assume that I know where the vdi file is and can access it. I know also that I can install virtualbox manager and then execute the shell in python. However I am looking for and existing library/API that avoid me to go through permission stuffs with shell. I tried pyvbox but it did not work. A simple find doesn't get the machine.
# I tried these two commands
vm = vbox.find_machine('test_vm')
vm2 = vbox.find_machine('path/to/test_vm')
I guess this is because the virtual machine test_vm is not registed to this instance. Any idea on how to do the cloning of already existing virtual machine from installed virtualbox?
looks like you're following the pyvbox documentation, but perhaps not correctly?
This is what I did (win10, python 2.7):
>>> pip install pyvbox
>>> python
Python 2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import virtualbox
>>> vbox = virtualbox.VirtualBox()
>>> print("VM(s):\n + %s" % "\n + ".join([vm.name for vm in vbox.machines]))
VM(s):
+ tails2.4a
+ Kali-Linux-testvm
+ lubuntu1610
>>> vm = vbox.find_machine('lubuntu1610')
>>> vm
<virtualbox.library_ext.machine.IMachine object at 0x0000000002D069B0>
You refer to 'session', I think you mean:
session = virtualbox.Session()
which (merely initiates a virtualbox session)is independent of your find_machine command. See below:
progress = vm.launch_vm_process(session, 'gui', '')
which basically launches that virtualbox.
I think that if your 'test_vm' machine really does exist (does it?? did you create it first in virtalbox?) it will be found just fine. Maybe just list your VMs first like I did:
print("VM(s):\n + %s" % "\n + ".join([vm.name for vm in vbox.machines]))
and then find_machine ? Or I have misunderstood what you're saying :p
In Python 2.7, how can I make the IDLE app use \__future__ division without typing from \__future__ import division manually every time I start IDLE?
If I put from \__future__ import division at the top of my .idlestartup file it is ignored, even though the other things in .idlestartup get executed. For example:
~> cat >.idlestartup
from __future__ import division
print("Executing .idlestartup")
~> idle -s
Here's what my IDLE window looks like after I try dividing:
Python 2.7.8 |Anaconda 2.1.0 (x86_64)| (default, Aug 21 2014, 15:21:46)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>>
Executing .idlestartup
>>> 2/3
0
>>>
I am using Mac OS X 10.9.5 Mavericks (also had the same problem on earlier versions of OS X). Note that the command line version above was included to make it easier to show what I'm talking about, but the version I'm more interested in is running the IDLE app from the GUI.
The solution suggested by Ashwini Chaudhary below worked for running the Anaconda version from the command line but not for running the IDLE app.
I was finally able to get future division working automatically in the IDLE app by adding "sys.argv.insert(1, '-Qnew')" to /Applications/IDLE.app/Contents/MacOS/IDLE. Both that and Ashwini Chaudhary's solution below seem brittle. I wonder if there is a cleaner way.
Adding the __future__ statement at the top of /usr/lib/python2.7/idlelib/PyShell.py did the job for me.
I am on Ubuntu, the path may vary for other OS:
>>> import idlelib
>>> idlelib.PyShell.__file__
'/usr/lib/python2.7/idlelib/PyShell.py'
I use Windows 7, 64bit, with installed Python 2.7 and Oracle instant client 10.2.0.3.
I try to set up connection with Oracle database from python. In order to do this, I download cx_Oracle-5.1.2-10g.win32-py2.7.msi and install it.
upd. it's an error. i meant cx_Oracle-5.1.2-10g.win-amd64-py2.7.msi
Then I try to connect use code like this
import cx_Oracle
ad = cx_Oracle.makedsn('127.0.0.1', '1521', 'XE')
con = cx_Oracle.connect('user', 'password', ad)
And check that connection is set up correctly by selecting some rows from database table.
And at this moment happens something interesting.
I perform described actions in three different environments: Sublime Text 3, Python Console and ipython.
The problem is in ST3 and in ipython this chunk of code silently crashes on line with cx_Oracle.connect (I checked that with print statement in different places).
But in python console and idle it works just fine. Moreover sometimes it works properly in ipython, but I cannot understand why and when. In ST3 it never works.
ST shows message [Finished in 0.4s with exit code 3221226356]
To demonstrate behavior in python and ipython console I attach copypaste of simple case from cmd. It just exits from ipython.
C:\Users\Alexey>python
Python 2.7.7 (default, Jun 1 2014, 14:21:57) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>> cx_Oracle.connect()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cx_Oracle.DatabaseError: ORA-12560: TNS:protocol adapter error
>>> exit()
C:\Users\Alexey>ipython
Python 2.7.7 (default, Jun 1 2014, 14:21:57) [MSC v.1500 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
IPython 2.2.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import cx_Oracle
In [2]: cx_Oracle.connect()
C:\Users\Alexey>
Where is the problem? How can I solve it?
Thanks in advance.
PS. I tried to handle exception in ST3 and ipython such as
try:
cx_Oracle.connect()
except Exception as e:
print e
but script terminates on cx_Oracle.connect() and no message appears.
I tried this environment myself and did not experience the same behavior. Perhaps use faulthandler or gdb or some equivalent to figure out where the crash is taking place? cx_Oracle is still maintained (by me) so if you can find a bug I'll happily fix it! It may also be a problem with IPython or ST3 or in some interaction between these two and cx_Oracle. Since I can't replicate the problem, however, you'll need to provide a stack trace of some sort so we can proceed further.
I'm trying to register the Firefox browser to run on Windows. According to the documentation for Webbrowser, "If the environment variable BROWSER exists, it is interpreted to override the platform default list of browsers, as a os.pathsep-separated list of browsers to try in order". I tried setting it, but it had no impact.
Z:\>SET BROWSER=C:\Program Files (x86)\Mozilla Firefox\firefox.exe %s
Z:\>python3
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (I
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import webbrowser
>>>
>>> webbrowser.open('http://google.com')
True
>>>
webbrowser.get("firefox") doesn't work either
How can I make webbrowser launch Firefox?
You might need to set static envionment viraibles, this you can do in the properties of my computer... Whether or not it will help is for you to figure out (worked over here..).
Another way to do this:
import webbrowser
webbrowser.get("open -a C:\\Program F~\\Mozilla Firefox\\firefox.exe %s")
webbrowser.open('http://google.com')
I'm trying to lean sqlite3 and create databases, but I'm having trouble getting started. I go to the Terminal and start things off by typing sqlite3. I get the following prompt:
sqlite>
I installed sqlAcademy and am trying to work through the tutorial, but with examples like:
>>> import sqlalchemy
>>> sqlalchemy.__version__
0.7.0
They appear to be typing in the Terminal, but my code shows an error:
sqlite> import sqlalchemy;
Error: near "import": syntax error
Is there a wrapper I should be using in Terminal so I can type in Python? Do I need to individually write, compile, and run all of the example or is there an easier way?
I know this sounds vague, but I think I'm doing something very obvious wrong. Just too new to know what it is.
That's because you're running in sqlite terminal. The sample code should be run from python's terminal.
To further expand on Demian's answer:
In the terminal type:
$ python
you will get (or similar depending on which version of python you have installed)
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
From there you can enter your import sqlalchemy
Alternatively you can create a python script file (*.py) and put your code in it. Then run run the code by changing to the directory that your files are in, and entering
python filename.py
Hope that helps.