I am using Python 2.7 on windows
I want to install a software called febrl on python which requires pygtk.glade
I have installed all the modules that were specified in the software manual, especially PYGTK all-in-one but i get an error when i try to import pygtk.glade (i have no error when i do : import pygtk)
import pygtk.glade
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named glade
Is there a way to install glade for python on windows?
Thank you
maybe you need to do from pygtk import glade
check this for more information:
http://www.pygtk.org/articles/pygtk-glade-gui/Creating_a_GUI_using_PyGTK_and_Glade.htm
Gtk.Builder and friends are already in the Gtk module included. So, if you
from gi.repository import Gtk
you have access to the builder. You do not need Glade inside your python code. Glade is an external tool (separate from Python) which generates an XML file (normally called yourproject.ui, yourproject.glade or so), which is the description of the GUI you designed.
In your code you then have to make an instance of GtkBuilder, and read the XML file. This will generate all the widgets and make them available in your program.
Have a look at this tutorial.
That same XML is also usable in many other languages using a similar process - call GtkBuilder, etc.
Run this command below and it solve all your missing dependencies:
apt-get install python python-gtk2 python-glade2 libgtk2.0-dev libsqlite3-0
By running pip search glade I get this
BabelGladeExtractor (0.2dev-r288) - Babel Glade XML files translatable strings extractor
BD (0.0.5) - Bangladesh Details with postal code
GladeBuilder (0.1.0) - Easy way to get and set values/properties of
Gtk2/Gtk3 widgets.
SPE (0.8.3.c) - Python IDE with Blender, Kiki, PyChecker, Remote debugger, Uml and wxGlade support
I am pretty sure doing either
pip install GladeBuilder
of
pip install SPE
will solve it. But then again you are on windows so it really depends.
Related
Im attempting to use the numpy module in webots but whatever I try I always get
INFO: assignment_2_controller_2: Starting controller: python3.6 -u "assignment_2_controller_2.py"
[assignment_2_controller_2] Traceback (most recent call last):
[assignment_2_controller_2] File "assignment_2_controller_2.py", line 4, in <module>
[assignment_2_controller_2] import numpy
[assignment_2_controller_2] ModuleNotFoundError: No module named 'numpy'
WARNING: 'assignment_2_controller_2' controller exited with status: 1.
I have installed numpy with both pip2 and pip3 and neither seem to have made any difference and the package shows up in ~/.local/lib/python3.6/site-packages. I can also confirm that this module works in the python editor and in other python files.
Is there perhaps something I need to change in webots python Makefile or perhaps in my environment variables?
Edit:
Printing sys.path shows
'/snap/webots/14/usr/share/webots/lib/controller/python36', '/snap/webots/14/usr/lib/python36.zip', '/snap/webots/14/usr/lib/python3.6', '/snap/webots/14/usr/lib/python3.6/lib-dynload', '/snap/webots/14/usr/lib/python3/dist-packages'
I installed webots using snap but why wouldnt it use the python dictated by the PATH environment variable?
Fix:
By the looks of it snap creates a contained filesystem for webots to run in by design in which it installed its own python binaries. I therefore uninstalled webots with snap and then installed from the .deb file off their website and now it works fine.
Webots installed from the Snap package is running in a kind of sandbox, it is therefore using the version of Python distributed with the snap package (which you can't alter).
As explained in the documentation, you might use external controllers to launch yourself the controller instead of letting Webots starting it. This way you can chose which version of Python you want to use: https://cyberbotics.com/doc/guide/installation-procedure#installing-the-snap-package
Alternatively, you can use a different way to install Webots (from the Debian or archive package). The other installations are not coming with Python and are using the system Python.
There is a bunch of pre-made code I simply have to run. However, the code requires the module NumPy, which for some reason is not installed. I am using Geany for the Python code, and when I click compile, the console states:
"Traceback (most recent call last):
File "chi2Fit.py", line 1, in <module>
import numpy as np
ImportError: No module named 'numpy'
I really tried to look it up, and I found the zipped NumPy packages on SourceForge, but I cannot install them. I am using Windows 10 (Virtual Machine is buggy, unfortunately). I usually run my Python programs by compiling them directly and don't use the commands within the console (so honestly I don't know how to open the command line. Yes, I am a beginner). What is the explanation?
Geany is just an editor, with the ability to run commands and such from menus and buttons. So you should be able to run this code 'by compiling them directly'. If that works while the 'geany compile' does not, then you need to check the 'compile' command. Is it using the right Python?
'compile' really doesn't make sense with Python code. You are just executing a script.
NumPy is a large package that does include compiled components. So installing it requires more than downloading a ZIP file. On Windows it is usually best to install one of the precompiled packages. Anaconda is popular one.
But we know nothing about this pre-made code, and whether it has included the necessary modules or not. You need to find out from the source of that code what is needed to run it.
You need to figure out how to install NumPy. It depends on what OS you are using.
There are pre-compiled packages for Windows. There is plenty of information here on SO (e.g., Installing NumPy on Windows) or you can use Google.
I have a prototype written in Python that I need to port into Java to put into production. Python 2.7.10 has been installed using miniconda. The prototype uses a 3rd party library nltk that I installed using pip.
To void rewriting the code from scratch, at least initially, I want to first try call the prototype code directly from Java using jython.
When I try executing a command like
java -jar jython-standalone-2.7.0.jar myPrototype.py
I get
Traceback (most recent call last):
File "myPrototype.py", line 4, in <module>
from nltk import AlignedSent
ImportError: No module named nltk
It works fine when I run python myPrototype.py.
Is there a way of configuring my jython install so that it can find all 3rd party packages that I've added to my python install? I realize that some of those might not run in jython but at least I want to have access to those that do.
The bulk of NLTK is Python code so you should be able to use it from Jython as long as it's in your module search path. If you are on unix just add a link to your nltk in site-packages to the current folder. Or look into the documentation here: http://www.jython.org/jythonbook/en/1.0/ModulesPackages.html
NLTK needs to be able to load its data for some stuff. You may want to either make al link to your nltk_data from your home to the current folder or see this answer to set it from code: How to config nltk data directory from code?
I have a simple sode snippet that uses cairomodule. I would like to launch the scipt but it somehow cannot run giving this error :
Traceback (most recent call last):
File "C:\Users\xxx\Desktop\test.py", line 1, in <module>
import cairo
ImportError: No module named cairo
how should I "install" a module in Python on Windows ? I have tried installing http://gladewin32.sourceforge.net/ as stated on cairo page that I can get cairo as a "side effect" of intalling GTK+ but somehow this didn't work.
If I should add some paths to PATH please indicate which one as I am raelly confused about this.
Now I realise how simpler that would be on linux with powerful terminal :)
Try installing PyGtk from here: http://www.pygtk.org/downloads.html. The all-in-one-installer worked for me. Just choose the packages you want installed.
I am on a Windows 7 64bit machine, using Python 2.7 and I am trying to use the python database library in robotframework. I have previously used a java library file but now I want to use the python library.
I have gone to github and downloaded version 0.6.
I have also installed a setup file and MySQL-python from here
However when I try to install the database library (using python setup.py build) I get the following error:
Traceback (most recent call last):
File "setup.py", line 25, in <module>
from DatabaseLibrary import __version__
File "src\DatabaseLibrary\__init__.py", line 15, in <module>
from connection_manager import ConnectionManager
File "src\DatabaseLibrary\connection_manager.py", line 16, in <module>
from robot.api import logger
ImportError: No module named api
Why do I not have robot.api and how do I get it and install it? Or is there an easier way to install the python database library?
It seems that the Database library uses Robot Framework internals, but does not list Robot Framework as it's dependency. The robot.api package was introduced in RF 2.6, so upgrading/installing the latest Robot Framework (from project pages) should resolve your issue
First ensure the integrity of your module before trying to install. In order to install a module using distutils (setup.py) you need to run this command as an administrator:
python setup.py install
That should run the setup and report back to you any missing dependencies.
Alternatively, you can install PIP from this location: PIP Project home page. Their page provides instructions how to install PIP, it's a package manager for Python, similar to PEAR for PHP, CPAN for Perl or gem for ruby. When you have it installed you can install packages with this command:
pip install <module>
The issue was I did not have the "API" folder in the "Robot" folder in "Python27\Lib\site-packages" as I did not have the latest version of RF. And logger is a new logging API for Robot Framework 2.6 since Oct 2011. (As janne as pointed out)
Two fixes for this issue seem to be:
Tested and worked but not recommended unless you dont want to update RF: Edit the 2 files "connection_manager.py" and "query.py" in "robotframework-databaselibrary-0.6" so that there is no dependency on the Robotframework logger. This is a easy and quick edit, where you replace the "from robot.api import logger" to "import logging" and "logger" to "logging"
See "http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html#programmatic-logging-apis" for more detail.
Reinstall Robotframework and ensure the "API" folder is created. This is recommended as it is the best approach.
(Added as an answer as too long for a comment)