Search Results

Search found 20092 results on 804 pages for 'python import'.

Page 4/804 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Convertion of tiff image in Python script - OCR using tesseract

    - by PYTHON TEAM
    I want to convert a tiff image file to text document. My code perfectly as I expected to convert tiff images with usual font but its not working for french script font . My tiff image file contains text. The font of text is in french script format.I here is my code import Image import subprocess import util import errors tesseract_exe_name = 'tesseract' # Name of executable to be called at command line scratch_image_name = "temp.bmp" # This file must be .bmp or other Tesseract-compatible format scratch_text_name_root = "temp" # Leave out the .txt extension cleanup_scratch_flag = True # Temporary files cleaned up after OCR operation def call_tesseract(input_filename, output_filename): """Calls external tesseract.exe on input file (restrictions on types), outputting output_filename+'txt'""" args = [tesseract_exe_name, input_filename, output_filename] proc = subprocess.Popen(args) retcode = proc.wait() if retcode!=0: errors.check_for_errors() def image_to_string(im, cleanup = cleanup_scratch_flag): """Converts im to file, applies tesseract, and fetches resulting text. If cleanup=True, delete scratch files after operation.""" try: util.image_to_scratch(im, scratch_image_name) call_tesseract(scratch_image_name, scratch_text_name_root) text = util.retrieve_text(scratch_text_name_root) finally: if cleanup: util.perform_cleanup(scratch_image_name, scratch_text_name_root) return text def image_file_to_string(filename, cleanup = cleanup_scratch_flag, graceful_errors=True): If cleanup=True, delete scratch files after operation.""" try: try: call_tesseract(filename, scratch_text_name_root) text = util.retrieve_text(scratch_text_name_root) except errors.Tesser_General_Exception: if graceful_errors: im = Image.open(filename) text = image_to_string(im, cleanup) else: raise finally: if cleanup: util.perform_cleanup(scratch_image_name, scratch_text_name_root) return text if __name__=='__main__': im = Image.open("/home/oomsys/phototest.tif") text = image_to_string(im) print text try: text = image_file_to_string('fnord.tif', graceful_errors=False) except errors.Tesser_General_Exception, value: print "fnord.tif is incompatible filetype. Try graceful_errors=True" print value text = image_file_to_string('fnord.tif', graceful_errors=True) print "fnord.tif contents:", text text = image_file_to_string('fonts_test.png', graceful_errors=True) print text

    Read the article

  • Errors related to python version added to error log when I start apache2

    - by Jean-Nicolas Boulay Desjardins
    When I start apache I am getting those errors: [Tue Jun 14 02:28:58 2011] [error] python_init: Python version mismatch, expected '2.6.5', found '2.6.6'. [Tue Jun 14 02:28:58 2011] [error] python_init: Python executable found '/usr/bin/python'. [Tue Jun 14 02:28:58 2011] [error] python_init: Python path being used '/usr/lib/python2.6/:/usr/lib/python2.6/plat-linux2:/usr/lib/python2.6/lib-tk:/usr/lib/python2.6/lib-old:/usr/lib/python2.6/lib-dynload'. [Tue Jun 14 02:28:58 2011] [notice] mod_python: Creating 8 session mutexes based on 150 max processes and 0 max threads. [Tue Jun 14 02:28:58 2011] [notice] mod_python: using mutex_directory /tmp [Tue Jun 14 02:28:58 2011] [notice] Apache/2.2.16 (Ubuntu) PHP/5.3.3-1ubuntu9.5 with Suhosin-Patch mod_python/3.3.1 Python/2.6.6 configured -- resuming normal operations I am using Ubuntu Server... Thanks in advance for any help.

    Read the article

  • Python and Ruby in Tuxedo

    - by Maurice Gamanho
    With the release of SALT 11gR1, you can now develop Python/Ruby services/applications on Oracle Tuxedo platform. Python functions or Ruby classes can be invoked as Tuxedo services by other Tuxedo services or clients and, in addition, Python/Ruby applications can invoke existing Tuxedo services. SALT 11gR1 combines the proven scalability, reliability and performance of the Tuxedo runtime infrastructure with the agility provided by these dynamic scripting languages, providing a highly available and almost linearly scalable platform for Python and Ruby application development. Another benefit of developing Python and Ruby applications with Tuxedo is that services are SOA enabled from inception by virtue of Tuxedo's comprehensive integration options with J2EE app servers, mainframe applications, Web services, etc. Other interesting features are dynamic re-loading of scripts, where script changes are picked up automatically or when the administrator decides, and server-side typing, where Python functions and Ruby classes are given interfaces by way of the Tuxedo Metadata Repository. More information can be found on the Oracle SALT 11gR1 documentation page. See also SCA Python and Ruby Programming and Python and Ruby Data Type Mapping.

    Read the article

  • ubuntu 12.04 python problem or?

    - by Trki
    Hi i am trying to fix this for a long time but without success. When i open my zsh terminal i get this error: (terminal is working but error appear) Welcome to the world of tomorrow! virtualenvwrapper_run_hook:12: permission denied: virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON= and that PATH is set properly. I tried few things but... dont know how to solve it. Somehow during looking for a search i found i should post here an output of: ? sudo dpkg --configure -a Setting up python-pip (1.0-1build1) ... /var/lib/dpkg/info/python-pip.postinst: 6: /var/lib/dpkg/info/python-pip.postinst: pycompile: not found dpkg: error processing python-pip (--configure): subprocess installed post-installation script returned error exit status 127 Setting up libc-dev-bin (2.15-0ubuntu10.5) ... Setting up gnome-control-center-data (1:3.4.2-0ubuntu0.13) ... Setting up linux-libc-dev (3.2.0-56.86) ... Setting up python-virtualenv (1.7.1.2-1) ... /var/lib/dpkg/info/python-virtualenv.postinst: 6: /var/lib/dpkg/info/python-virtualenv.postinst: pycompile: not found dpkg: error processing python-virtualenv (--configure): subprocess installed post-installation script returned error exit status 127 Setting up libglib2.0-0 (2.32.4-0ubuntu1) ... Setting up libglib2.0-0:i386 (2.32.4-0ubuntu1) ... Setting up gimp (2.6.12-1ubuntu1.2) ... /var/lib/dpkg/info/gimp.postinst: 11: /var/lib/dpkg/info/gimp.postinst: pycompile: not found dpkg: error processing gimp (--configure): subprocess installed post-installation script returned error exit status 127 Setting up libpolkit-gobject-1-0 (0.104-1ubuntu1.1) ... Setting up libgnome-control-center1 (1:3.4.2-0ubuntu0.13) ... Setting up libnm-util2 (0.9.4.0-0ubuntu4.3) ... Setting up libc6-dev (2.15-0ubuntu10.5) ... Setting up libpulse-mainloop-glib0 (1:1.1-0ubuntu15.4) ... dpkg: dependency problems prevent configuration of virtualenvwrapper: virtualenvwrapper depends on python-virtualenv; however: Package python-virtualenv is not configured yet. dpkg: error processing virtualenvwrapper (--configure): dependency problems - leaving unconfigured Setting up libpolkit-agent-1-0 (0.104-1ubuntu1.1) ... Setting up libupower-glib1 (0.9.15-3git1ubuntu0.1) ... Setting up libaccountsservice0 (0.6.15-2ubuntu9.6.1) ... Setting up libpolkit-backend-1-0 (0.104-1ubuntu1.1) ... Setting up libglib2.0-bin (2.32.4-0ubuntu1) ... Setting up libnm-glib4 (0.9.4.0-0ubuntu4.3) ... Setting up policykit-1 (0.104-1ubuntu1.1) ... Setting up gnome-settings-daemon (3.4.2-0ubuntu0.6.4) ... Setting up accountsservice (0.6.15-2ubuntu9.6.1) ... dpkg: error processing ubuntu-system-service (--configure): Package is in a very bad inconsistent state - you should reinstall it before attempting configuration. Processing triggers for libc-bin ... ldconfig deferred processing now taking place Errors were encountered while processing: python-pip python-virtualenv gimp virtualenvwrapper ubuntu-system-service Also: ? python --version zsh: command not found: python Part of my ~/.zshrc # python virtual env wrapper if [ -f ~/.local/bin/virtualenvwrapper.sh ]; then export WORKON_HOME=~/.virtualenvs source ~/.local/bin/virtualenvwrapper.sh plugins=("${plugins[@]}" virtualenvwrapper) fi # pythonbrew [[ -s ~/.pythonbrew/etc/bashrc ]] && source ~/.pythonbrew/etc/bashrc Part os zsh -xv # # Invoke the initialization functions # virtualenvwrapper_initialize +/home/trki/.local/bin/virtualenvwrapper.sh:1179> virtualenvwrapper_initialize +virtualenvwrapper_initialize:1> virtualenvwrapper_derive_workon_home +virtualenvwrapper_derive_workon_home:1> typeset 'workon_home_dir=/home/trki/.virtualenvs' +virtualenvwrapper_derive_workon_home:5> [ /home/trki/.virtualenvs '=' '' ']' +virtualenvwrapper_derive_workon_home:12> echo /home/trki/.virtualenvs +virtualenvwrapper_derive_workon_home:12> unset GREP_OPTIONS +virtualenvwrapper_derive_workon_home:12> grep '^[^/~]' +virtualenvwrapper_derive_workon_home:21> echo /home/trki/.virtualenvs +virtualenvwrapper_derive_workon_home:21> unset GREP_OPTIONS +virtualenvwrapper_derive_workon_home:21> egrep '([\$~]|//)' +virtualenvwrapper_derive_workon_home:30> echo /home/trki/.virtualenvs +virtualenvwrapper_derive_workon_home:31> return 0 +virtualenvwrapper_initialize:1> export 'WORKON_HOME=/home/trki/.virtualenvs' +virtualenvwrapper_initialize:3> virtualenvwrapper_verify_workon_home -q +virtualenvwrapper_verify_workon_home:1> RC=0 +virtualenvwrapper_verify_workon_home:2> [ ! -d /home/trki/.virtualenvs/ ']' +virtualenvwrapper_verify_workon_home:11> return 0 +virtualenvwrapper_initialize:6> [ /home/trki/.virtualenvs '=' '' ']' +virtualenvwrapper_initialize:11> virtualenvwrapper_run_hook initialize +virtualenvwrapper_run_hook:1> typeset hook_script +virtualenvwrapper_run_hook:2> typeset result +virtualenvwrapper_run_hook:4> hook_script=+virtualenvwrapper_run_hook:4> virtualenvwrapper_tempfile initialize-hook +virtualenvwrapper_tempfile:2> typeset 'suffix=initialize-hook' +virtualenvwrapper_tempfile:3> typeset file +virtualenvwrapper_tempfile:5> file=+virtualenvwrapper_tempfile:5> virtualenvwrapper_mktemp -t virtualenvwrapper-initialize-hook-XXXXXXXXXX +virtualenvwrapper_mktemp:1> mktemp -t virtualenvwrapper-initialize-hook-XXXXXXXXXX +virtualenvwrapper_tempfile:5> file=/tmp/virtualenvwrapper-initialize-hook-OhY86PXmo7 +virtualenvwrapper_tempfile:6> [ 0 -ne 0 ']' +virtualenvwrapper_tempfile:6> [ -z /tmp/virtualenvwrapper-initialize-hook-OhY86PXmo7 ']' +virtualenvwrapper_tempfile:6> [ ! -f /tmp/virtualenvwrapper-initialize-hook-OhY86PXmo7 ']' +virtualenvwrapper_tempfile:11> echo /tmp/virtualenvwrapper-initialize-hook-OhY86PXmo7 +virtualenvwrapper_tempfile:12> return 0 +virtualenvwrapper_run_hook:4> hook_script=/tmp/virtualenvwrapper-initialize-hook-OhY86PXmo7 +virtualenvwrapper_run_hook:11> cd /home/trki/.virtualenvs +cd:1> [[ x/home/trki/.virtualenvs == x... ]] +cd:3> [[ x/home/trki/.virtualenvs == x.... ]] +cd:5> [[ x/home/trki/.virtualenvs == x..... ]] +cd:7> [[ x/home/trki/.virtualenvs == x...... ]] +cd:9> [ -d /home/trki/.autoenv ']' +cd:13> cd /home/trki/.virtualenvs +virtualenvwrapper_run_hook:12> '' -m virtualenvwrapper.hook_loader --script /tmp/virtualenvwrapper-initialize-hook-OhY86PXmo7 initialize virtualenvwrapper_run_hook:12: permission denied: +virtualenvwrapper_run_hook:15> result=126 +virtualenvwrapper_run_hook:17> [ 126 -eq 0 ']' +virtualenvwrapper_run_hook:27> [ initialize '=' initialize ']' +virtualenvwrapper_run_hook:29> cat - virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON= and that PATH is set properly. +virtualenvwrapper_run_hook:38> rm -f /tmp/virtualenvwrapper-initialize-hook-OhY86PXmo7 +virtualenvwrapper_run_hook:39> return 126 +virtualenvwrapper_initialize:13> virtualenvwrapper_setup_tab_completion +virtualenvwrapper_setup_tab_completion:1> [ -n '' ']' +virtualenvwrapper_setup_tab_completion:20> [ -n 4.3.17 ']' +virtualenvwrapper_setup_tab_completion:30> compctl -K _virtualenvs workon rmvirtualenv cpvirtualenv showvirtualenv +virtualenvwrapper_setup_tab_completion:31> compctl -K _cdvirtualenv_complete cdvirtualenv +virtualenvwrapper_setup_tab_completion:32> compctl -K _cdsitepackages_complete cdsitepackages +virtualenvwrapper_initialize:15> return 0 +/home/trki/.zshrc:17> plugins=( git python django symfony2 zsh-syntax-highlighting composer history-substring-search virtualenvwrapper ) # pythonbrew [[ -s ~/.pythonbrew/etc/bashrc ]] && source ~/.pythonbrew/etc/bashrc +/home/trki/.zshrc:21> [[ -s /home/trki/.pythonbrew/etc/bashrc ]] Also when i try to open ubuntu software center absolutly nothing happens. No idea what to do now.

    Read the article

  • "Cannot import name genshi" error when installing the Swab library

    - by ATMathew
    I'm trying to install the Swab library for Python 2.6 in Ubuntu 10.10. However, I get the following error messages when I try to import it. In the terminal I ran: sudo easy_install swab sudo easy_install Genshi In the Python interpreter I ran: >>> import swab Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.6/dist-packages/swab-0.1.2-py2.6.egg/swab/__init__.py", line 23, in <module> from pestotools.genshi import genshi, render_docstring ImportError: cannot import name genshi I don't know whats going on. can anyone help.

    Read the article

  • Python-How to call up a function from another module?

    - by user2691540
    I am making a project where I need several modules which are imported into one main module to make a pizza ordering service. Upon finishing this (to a working standard) I decided to re-code it so that the whole order is completed with one tkinter window, now instead of using input(), I use tkinter.Entry() etc. etc. To do this I had to use functions for each step so it is broken up nicely, e.g. the code asks if the user wants pickup or delivery, the user clicks a button which sets some variables and one of the buttons is then configured to say "continue" and the command leads to the next step of the pizza ordering process e.g. getting the name. The problem I have is that when I get past the last function of the first module the configured button has a command to go to a function in the second module, but it says that the command is not defined??? I have tried my way around this but cannot import the configured button variable into the next module, and anything else I tried gave no result, it simply doesn't go to the next module after the first module is done. I have made the main tkinter window in the main module and have it that it will mainloop after importing the other modules so shouldn't the function I want to call upon be defined? How can I get from one function to the next if the latter is in a seperate module? Is this possible or do I have to rethink my approach and if so how? Ok then, have made some more code to show what my problem is, this isn't what I am actually using but it's a lot shorter and has the same issue: this is the main module: import tkinter mainwindow = tkinter.Tk() # here i set the window to a certain size etc. import mod1 import mod2 mainwindow.mainloop() this is mod1: import tkinter def button1(): label.destroy() button1.destroy() button2.config(text = "continue", command = func2) def button2(): label.destroy() button1.destroy() button2.config(text = "continue", command = func2) label = tkinter.Label(text = "example label") button1 = tkinter.Button(text = "button1", command = button1) button2 = tkinter.Button(text = "button2", command = button2) label.pack() button1.pack() button2.pack() this is mod2: def func2(): button2.destroy() print ("haha it works...") I still get the problem that func2 is not defined? Thanks in advance

    Read the article

  • Tkinter on Ubuntu 14.04 seems not to work

    - by empedokles
    I receive following Traceback: Traceback (most recent call last): File "tkinter_basic_frame.py", line 4, in <module> from Tkinter import Tk, Frame, BOTH File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in raise ImportError, str(msg) + ', please install the python-tk package' ImportError: No module named _tkinter, please install the python-tk package This is the demoscript I'm trying to run: #!/usr/bin/python # -*- coding: utf-8 -*- from Tkinter import Tk, Frame, BOTH class Example(Frame): def __init__(self, parent): Frame.__init__(self, parent, background="white") self.parent = parent self.initUI() def initUI(self): self.parent.title("Simple") self.pack(fill=BOTH, expand=1) def main(): root = Tk() root.geometry("250x150+300+300") app = Example(root) root.mainloop() if __name__ == '__main__': main() From my knowledge Tkinter should be included in Python 2.7. Why do I receive the traceback? Doesn't ubuntu contain the standard-python-distribution? This is solved. I had to install it manually in synaptic (got the hint in the meantime from another forum), see here: Wikipedia says: "Tkinter is a Python binding to the Tk GUI toolkit. It is the standard Python interface to the Tk GUI toolkit1 and is Python's de facto standard GUI,2 and is included with the standard Windows and Mac OS X install of Python." - Not good, that it isn't included in Ubuntu as well. Tkinter on Wikipedia

    Read the article

  • python/pip error on osx

    - by Ibrahim Chawa
    I've recently purchased a new hard drive and installed a clean copy of OS X Mavericks. I installed python using homebrew and i need to create a python virtual environment. But when ever i try to run any command using pip, I get this error. I haven't been able to find a solution online for this problem. Any reference would be appreciated. Here is the error I'm getting. ERROR:root:code for hash md5 was not found. Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 139, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type md5 ERROR:root:code for hash sha1 was not found. Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 139, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha1 ERROR:root:code for hash sha224 was not found. Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 139, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha224 ERROR:root:code for hash sha256 was not found. Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 139, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha256 ERROR:root:code for hash sha384 was not found. Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 139, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha384 ERROR:root:code for hash sha512 was not found. Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 139, in <module> globals()[__func_name] = __get_hash(__func_name) File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha512 Traceback (most recent call last): File "/usr/local/bin/pip", line 9, in <module> load_entry_point('pip==1.5.6', 'console_scripts', 'pip')() File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 356, in load_entry_point File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 2439, in load_entry_point File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 2155, in load File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/__init__.py", line 10, in <module> from pip.util import get_installed_distributions, get_prog File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/util.py", line 18, in <module> from pip._vendor.distlib import version File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/_vendor/distlib/version.py", line 14, in <module> from .compat import string_types File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/_vendor/distlib/compat.py", line 31, in <module> from urllib2 import (Request, urlopen, URLError, HTTPError, ImportError: cannot import name HTTPSHandler If you need any extra information from me let me know, this is my first time posting a question here. Thanks.

    Read the article

  • How to import classes into other classes within the same file in Python

    - by Chris
    I have the file below and it is part of a django project called projectmanager, this file is projectmanager/projects/models.py . Whenever I use the python interpreter to import a Project just to test the functionality i get a name error for line 8 that FileRepo() cannot be found. How Can I import these classes correctly? Ideally what I am looking for is each Project to contain multiple FileRepos which each contain and unknown number of files. Thanks for any assistance in advance. #imports from django.db import models from django.contrib import admin #Project is responsible for ensuring that each project contains all of the folders and file storage #mechanisms a project needs, as well as a unique CCL# class Project(models.Model): ccl = models.CharField(max_length=30) Techpacks = FileRepo() COAS = FileRepo() Shippingdocs = FileRepo() POchemspecs = FileRepo() Internalpos = FileRepo() Finalreports = FileRepo() Batchrecords = FileRepo() RFPS = FileRepo() Businessdev = FileRepo() QA = FileRepo() Updates = FileRepo() def __unicode__(self): return self.ccl #ProjectFile is the file object used by each FileRepo component class ProjectFile(models.Model): file = models.FileField(uploadto='ProjectFiles') def __unicode__(self): return self.file #FileRepo is the model for the "folders" to be used in a Project class FileRepo(models.Model): typeOf = models.CharField(max_length=30) files = models.ManyToManyField(ProjectFile) def __unicode__(self): return self.typeOf

    Read the article

  • Eclipse and python: library will import in interprer, but not in IDE

    - by John
    I'm running Windows 7, Python 2.6.4 and the latest version of Eclipse. I downloaded the boto library (http://code.google.com/p/boto/) and ran python setup.py install, which created boto-1.9b-py2.6.egg in C:\Python26\Lib\site-packages. Importing a class - say, by doing 'from boto.sqs.connection import SQSConnection' - works fine from the python command line tool. But Eclipse will not find boto, despite the fact that it is using the same python interpreter as I am using when at the command line. I added the library as an external source folder, but that didn't work either. How can I properly import the boto library into Eclipse? Thanks.

    Read the article

  • Problem about python import with error

    - by xiao
    Hello, I have write a small python module with one class and two functions. The skeleton of the module is as following: #file name: test_module.py class TestClass: @classmethod def method1(cls, param1): #to do something pass def __init__(self, param1): #to do something ... def fun1(*params): #to do something ... def fun2(*params): #to do something ... Another py file is a small script which imports function and class from the module, as following: import sys from test_module import TestClass, fun1, fun2 def main(sys_argv): li = range(5) inst1 = TestClass(li) fun1(inst1) fun2(inst1) return if __name__ == "__main__": main(sys.argv) But when I execute the script, it is broken with following message: ./script.py: line 4: syntax error near unexpected token `(' ./script.py: line 4: `def main(sys_argv):' I am not sure what the problem is. Is it a problem with import? But when I try to import the module in ipython, everything is just ok.

    Read the article

  • Import a python module without the .py extension

    - by compie
    I have a file called foobar (without .py extension). In the same directory I have another python file that tries to import it: import foobar But this only works if I rename the file to foobar.py. Is it possible to import a python module that doesn't have the .py extension?

    Read the article

  • Pyjamas import statements

    - by Gordon Worley
    I'm starting to use Pyjamas and I'm running into some annoyances. I have to import a lot of stuff to make a script work well. For example, to make a button I need to first from pyjamas.ui.Button import Button and then I can use Button. Note that import pyjamas.ui.Button and then using Button.Button doesn't work (results in errors when you build to JavaScript, at least in 0.7pre1). Does anyone have a better example of a good way to do the import statements in Pyjamas than what the Pyjamas folks have on their site? Doing things their way is possible, but ugly and overly complicated from my perspective, especially when you want to use a dozen or more ui components.

    Read the article

  • Crossed import in django

    - by Kuhtraphalji
    On example, i have 2 apps: alpha and beta in alpha/models.py import of model from beta.models and in beta/models.py import of model from alpha.models manage.py validate says that ImportError: cannot import name ModelName how to solve this problem?

    Read the article

  • How to import a module from PyPI when I have another module with the same name

    - by kuzzooroo
    I'm trying to use the lockfile module from PyPI. I do my development within Spyder. After installing the module from PyPI, I can't import it by doing import lockfile. I end up importing anaconda/lib/python2.7/site-packages/spyderlib/utils/external/lockfile.py instead. Spyder seems to want to have the spyderlib/utils/external directory at the beginning of sys.path, or at least none of the polite ways I can find to add my other paths get me in front of spyderlib/utils/external. I'm using python2.7 but with from __future__ import absolute_import. Here's what I've already tried: Writing code that modifies sys.path before running import lockfile. This works, but it can't be the correct way of doing things. Circumventing the normal mechanics of importing in Python using the imp module (I haven't gotten this to work yet, but I'm guessing it could be made to work) Installing the package with something like pip install --install-option="--prefix=modules_with_name_collisions" package_name. I haven't gotten this to work yet either, but I'm guess it could be made to work. It looks like this option is intended to create an entirely separate lib tree, which is more than I need. Source Using pip install --target=lockfile_from_pip. The files show up in the directory where I tell them to go, but import doesn't find them. And in fact pip uninstall can't find them either. I get Cannot uninstall requirement lockfile-from-pip, not installed and I guess I will just delete the directories and hope that's clean. Source So what's the preferred way for me to get access to the PyPI lockfile module?

    Read the article

  • "ImportError: cannot import name Exchange" when using Celery w/ Kombu installed

    - by alukach
    I'm trying to create a Celery worker node on an Amazon EC2 Windows2008 R2 instance. Due to a plugin we require for another Python module, we are required to user Python3. I've installed Python3.2 and necessary modules and run Celery, but for some reason it states that it can't import Exchange and Queue from Kombu, despite the face that Kombu is installed and can be imported by python. Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\Administrator>celery Traceback (most recent call last): File "C:\Python32\Scripts\celery-script.py", line 9, in <module> load_entry_point('celery==3.0.11', 'console_scripts', 'celery')() File "C:\Python32\lib\site-packages\celery\__main__.py", line 13, in main from celery.bin.celery import main File "C:\Python32\lib\site-packages\celery\bin\celery.py", line 21, in <module> from celery.utils import term File "C:\Python32\lib\site-packages\celery\utils\__init__.py", line 22, in <module> from kombu import Exchange, Queue ImportError: cannot import name Exchange C:\Users\Administrator>python Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from kombu import Exchange, Queue >>> print('WTF?!?') WTF?!? >>> This problem seems similar to this and this, but I have not been able to remedy the issue. Any ideas?

    Read the article

  • May I know what python is great at [on hold]

    - by user108437
    I am amazed by python on how tidy the code is, so i decided to learn it, and 2 days pass and I am completely in love with python, but I just code it for hobby thing like chatting robot, uploading to file hosting scripts, etc that small tools for my own daily internet life, and not much for work. I can't find a real life usage of python here. I live in Singapore, when I see in the job skill needed, from those companies hiring, only one asking for python. so I begin to be doubtful whether this skill of mine really worth my time investing it? I also heard about django, and don't know how much popular it is comparing to asp.net. So i ask your help to tell me your country and how popular python there and whether you like python or not? I really like python because of the easy scripting language (not complicated like C++) but the usefulness is almost near C++ where many open source library out there that can run both in windows and linux, so the portability is great! i just want to justify my time for learning python, as because my job does not require python, and I don't have much time at home to learn something new.

    Read the article

  • Why is Python slower than Java but faster than PHP

    - by good_computer
    I have many times seen various benchmarks that show how a bunch of languages perform on a given task. Always these benchmarks reveal that Python is slower then Java and faster than PHP. And I wonder why is that the case. Java, Python, and PHP run inside a virtual machine All three languages convert their programs into their custom byte codes that run on top of OS -- so none is running natively Both Java and Python can be "complied" (.pyc for Python) but the __main__ module for Python is not compiled Python and PHP are dynamically typed and Java statically -- is this the reason Java is faster, and if so, please explain how that affects speed. And, even if the dynamic-vs-static argument is correct, this does not explain why PHP is slower than Python -- because both are dynamic languages. You can see some benchmarks here and here, and here

    Read the article

  • Why doesn't Python have a "flatten" function for lists?

    - by Hubro
    Erlang and Ruby both come with functions for flattening arrays. It seems like such a simple and useful tool to add to a language. One could do this: >>> mess = [[1, [2]], 3, [[[4, 5]], 6]] >>> mess.flatten() [1, 2, 3, 4, 5, 6] Or even: >>> import itertools >>> mess = [[1, [2]], 3, [[[4, 5]], 6]] >>> list(itertools.flatten(mess)) [1, 2, 3, 4, 5, 6] Instead, in Python, one has to go through the trouble of writing a function for flattening arrays from scratch. This seems silly to me, flattening arrays is such a common thing to do. It's like having to write a custom function for concatenating two arrays. I have Googled this fruitlessly, so I'm asking here; is there a particular reason why a mature language like Python 3, which comes with a hundred thousand various batteries included, doesn't provide a simple method of flattening arrays? Has the idea of including such a function been discussed and rejected at some point?

    Read the article

  • error installing python wrapper for openkinect

    - by auraham
    I tried to install python wrappers for OpenKinect on Ubuntu 12.04, but I can't due this error: $ sudo apt-get install python2.7-dev python2.7-dev : Depends: libexpat1-dev but it is not going to be installed Depends: libssl-dev but it is not going to be installed E: Unable to correct problems, you have held broken packages. Python wrapper requires these dependencies: Cython python-dev (error above) python-numpy how can I install python-dev?

    Read the article

  • Force import module from Python standard library instead of PYTHONPATH default

    - by jrdioko
    I have a custom module in one of the directories in my PYTHONPATH with the same name as one of the standard library modules, so that when I import module_name, that module gets loaded. If I want to use the original standard library module, is there any way to force Python to import from the standard library rather than from the PYTHONPATH directory, short of renaming the custom module and changing every reference to point to the new name?

    Read the article

  • Python: import the containing package

    - by guy
    In a module residing inside a package, i have the need to use a function defined within the __init__.py of that package. how can i import the package within the module that resides within the package, so i can use that function? Importing __init__ inside the module will not import the package, but instead a module named __init__, leading to two copies of things with different names... Is there a pythonic way to do this?

    Read the article

  • what does "from MODULE import _" do in python?

    - by Paul
    Hi all, In the Getting things gnome code base I stumbled upon this import statement from GTG import _ and have no idea what it means, never seen this in the documentation and a quick so / google search didn't turn anything up. Thank you all in advance Paul

    Read the article

  • calling a different python interpreter from bash command line

    - by Dennis Daniels
    I have python 2.7 installed [user@localhost google_appengine]$ python Python 2.7 (r27:82500, Sep 16 2010, 18:03:06) [GCC 4.5.1 20100907 (Red Hat 4.5.1-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. I want to use the python 2.5.2 that is in this directory [user@localhost Downloads]$ ls |grep "Python-2*" Python-2.5.2 Python-2.5.2.tgz to run a python script in Khan Academy platform against a google app engine application sudo python sample_data.py -a ~/workspace/GAE/google_appengine/appcfg.py upload Currently, when running the last script 2.7 python complains a lot (Google App Engine runs on 2.5.2 mostly and 2.6 almost) I would like to do something like sudo python env set ~/Downloads/Python-2.5.2 sample_data.py -a ~/workspace/GAE/google_appengine/appcfg.py upload Is this possible? If yes, please point the way. If not, please suggest a way to call python2.5.2 WITHOUT having to uninstall python 2.7 many many thanks Dennis

    Read the article

  • CentOS (rel6) with default python 2.6, but seperate 3.3.5 installation

    - by Silvertiger
    I have a CentOS server (rel6) that had python installed (2.6), but I needed a few features in 3.3+. I installed 3.3 into a seperate folder and made a symbolic link to execute it: I installed setup tools: yum install python-setuptools I installed a needed module"pandas" easy_install pandas I executed my pyton script, which encountered an error that required i use a newer version I downloaded and installed Python 3.3.5 to it's own folder so as to not override my default python wget http://www.python.org/ftp/python/3.3.5/Python-3.3.5.tar.xz tar xJf ./Python-3.3.5.tar.xz cd ./Python-3.3.5 ./configure --prefix=/opt/python make make install Made s symbolic link to allow me to execute this new python: ln -s /opt/python3.3/bin/python3.3 ~/bin/py The problem is that when I execute the python script with my new py alias, it does not have all the addons needed (explicitly MySQLdb) which the default install does. How do i go about installing the MySQLdb module, or any for that matter, to be reachable or useable for the new Python 3.3.5 installation? Or is there a way to make the current modules in 2.6 available to 3.3.5 as well?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >