Showing posts with label python part - 002. Show all posts
Showing posts with label python part - 002. Show all posts

4/16/2015

pip.exe runtime error : Python

# Introduction : Fatal error in launcher, Unable to create process using 'C:\Python27\python.exe'   'C:\Python27\Scripts\pip.exe'
This error is because of change in Python environment, to fix it, all you have to do is, tell every program which is not running about this new python environment.

like LINUX command line applications, first line is for program selection, for example,
=> If you are writing a bash script, first line of script will be,
#!/usr/bin/env bash
OR
#!/bin/bash

=> If you are writing a python executable script, first line of script will be,
#!/usr/bin/env python2.7
OR
#!/usr/opt/python27/python2.7
OR
#!/usr/local/bin/python2.7

So, this first line is about, how and using which program, you want to execute it, and where is that program , which you installed.
If you had changed path of this program executable, you also have to tell all your scripts about it, If path to this program is absolute.

#!/usr/bin/env python
This line of code is going to ask  env  program, about absolute location of python executable, if python executable is inside System PATH environment variable (Directories).

# General Solution:-
=> If your python script (like, pip.exe, pip2.exe, easy_install.exe, ipython.exe) do not know about, new location of python interpreter,
then you are going to tell it about python, either by embedding new location of python interpreter or invoking that script with python interpreter.



# Method 1:-
=> Using Python Interpreter (invoke python script with python script executable )
(After adding, python.exe into System PATH environment variable)
You can invoke any python module, using python interpreter, like this

python -m pip install ipython

(select python module named, pip and pass two command line arguments, install, and ipython)

# Method 2:-
=> Using Hex Editor to update new location/path for Python Interpreter.
If all you have is pip.exe (, pip2.exe, easy_install.exe, ipython.exe) instaed of pip.py
then, How your python script knows about python interpreter location/path.
Well, location/path of python interpreter is embeded into it, and you are going to edit it using Hex editor,
A good Hex Editor is Neo Hex Editor, that is Free for personal/limited use.

=> Open  pip.exe using Hex Editor of your choice.
Look for  Python  string inside pip.exe
Program will locate something like this,
#!C:\Python27\python.exe

<Image>
__python_error_before_hex_editing



All you have to do is,
Either change this path to new absolute path to python interpreter.
OR
Edit it like so, (You are telling this script to look for a program name python.exe, which is inside system path environment variable Directories)
#!python.exe


<Image>
__python_error_after_hex_editing


# Method 3:-
=> Using 7zip program to extract __main__.py script from pip.exe (or other similar program, which is showing this runtime error)
=> type __main__.py

# -*- coding: utf-8 -*-
import re
import sys

from pip import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

=> save as this file to pip.py in Script Directory.
=> If you want to invoke this program, use python interpreter.
python pip.py install ipython

=> If you like then you can also create a Batch file ( pip.bat )
@echo off
python %~dp0pip.py %*

# Remember,
%cd%    => expands to current working directory
after expanf   =>  example ,    ( D:\cmder\bin )
%~dp0   => expands to script directory ( where script file in resides on file-system )
after expand   =>  example ,   ( D:\cmder\bin\ )



1/21/2015

Custom Build System for Python : Sublime-Text-3


# Result ( For Linux ):- 
    # Allow you to run Python Script Directly, Just hit CTRL+B
    # Debug your Python script easily using IPython Terminal/Console.
        # So, You have a Python Script and there is something that you want to check out after completion of Python Script. then you need to Hit SHIFT+CTRL+B keys.
        # So that Sublime runs build+run command, So far we have defined that first we want to execute our script using IPython interactive environment and then we want to take a look at Objects/Variables/results/output generated by our Python script.



# Sublime 3: Custom Build System Script for Python :-


{
    "shell_cmd": "xterm -hold -e python \"$file\"",
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python, source.py",

    "variants":
    [
        {
            "name": "Run",
            "shell_cmd": "xterm -fg green -hold -e ipython -i \"${file}\""
        }
    ]
}

4/29/2014

Visual Image Manager - Build Using Python

Visual Image Manager - Build Using Python



    #@ Contents
#1: Introduction
#2: Tutorial
#3: Download
#3.1: https://sourceforge.net/projects/visualimageviewer/
#4: Documentation
##4.1 : Supported file formats
http://pillow.readthedocs.org/en/latest/handbook/image-file-formats.html 
##4.2 : What You Will Learn from This script.
#5: FAQ

So, let's take a look at, What is Visual Image Manager:
#1: Introduction

    Visual Image Manager :: Allows you to manage Image Visually, Instead of just coping and pasting to
given location, You can Do this using This Application, just by pressing defined keys.

Listen, I had 8000 Images on to my computer, and Today I looking for a way to manage my all images so
that these will be usefull.

How to Manage Images: (There are Two ways. )
##1: Manage Manually, ( Copy and paste to defined locations )
##2: Use This Application

##@ What Do you mean By Defined Location.
Defined Locations are just PATH to some directories or folders,
just like that, I said, Where is Your Desktop on Your Computer, You said, "C:\Users\S\Desktop"
so , C:\Users\S\Desktop is a defined location with in Your computer Envirenment.

Note for Windows Users :: Remember that, In Python language,
    "C:\Users\S\Desktop"( Do not Use This PATH Notation In Python ) == "C:\\Users\\S\\Desktop"( use This PATH )
    So, Learn this while working on windows with PATHS.

But Before Managing a lot of Image Files, using this Program you have to define your own custom locations, so that
Later You can use all these locations with refrence to a defined KEYBOARD KEY.

#2: Tutorial
    This application has 3 modes for Image Management,

    1: Image Slide Maker
        ( This Application will use a Time-Gap value, which is defined as the time in seconds between two frames of Images. )
        ( You might listen FPS - for a Video File, which refers for Frame per seconds, )
        ( But In This case, we use Time-Gap, means Tell your Computer, Hey Wait for 0.5 seconds before viewing next Image. )
        ( Higher the Value of time-Gap, slower will be rate of Image Management. )
        ( Great when you have some time to view your All Images without pressing a key. )

    2: Image Browser
        ( Manually Browse Image files. )
        ( You have to use KeyBoard Right-Key to view Next Image. )

    3: Image Manager



        ( Great When you are working with a lot of Image Files. )
        ( Create a DataBase for all Image Files That stored in a given computer PATH/ location )
        ( Now explore all image and manage all of them according to Defined locations. )
        ( By default you can define only 10 locations in this program, but your can define and extend the functionality of this Python Script. )
        ( Before Defining locations for this script, keep In mind that, you first location,
        means NUMPAD-KEY_0 , Hey!!, This is what I defined in this Program.)
        ( similarly location-number-2, means NUMPAD-KEY_1 )
        ( This simply means, suppose currently you have defined location-1 as \media\ssp\DATA\task\Nature, and I press NUMPAD-KEY_0
        Than That Image Will be Automatically copied to This Location-1 )

        ( Do not Worry for Duplicate files or Image Files with same name and same directory, Because time is a unique quantity,
        so I define Concatenation of time to the file name if found two Images With Same Name, later you can found , Hey these are All those image
        files with same name, So you Know better How to deal with Image files with same name, Now visually you can say that, Hey This is a Duplicate file.)

        ( NOTE:- If you have changed any file name or delete/move any Image File from your defined cwd location, than next time Before running this Program
        You have to reload the DataBase, Because DataBase has been Corupted and Should be re-created. )
        ( Re-loading Image DataBase means :: just delete "imagelist_data.dump" file, which you will found in cwd, ( cwd means, from which computer PATH
            you are running this Script. ))


#3: Download
##1: Linux users
    Download Python Script ( Need to install Numpy, Pillow, Tkinter )
    Download Portable-Linux-Package_Build _Using-CDE

##2: Windows users
    Download Python Script ( If You have installed Python Interpreter, )
    Download Portable- Visual Image Manager ( If you do not Have Python or you are a Simple Computer User, )
    Download Windows Installer ( Install this Application to Your Computer. )

##3: For Mac-OS Users
    Download Python Script

#4: Documentation
##1: If you are a Windows User:


## Script started ##