unattended install of binary python packages (modules) for windows - python

Is there no sane way to peform a scripted install of binary python packages for windows? Unfortunately it seems like several essential windows python packages like pywin32 and py2exe are only available as EXE's not MSI's (and as far as I know only the latter are scriptable). Easy_install/pip also seems no use since they apparently only find source packages and then try to compile locally which is obviously unsatisfactory.
Am I missing something?

You can download the source code of pywin32 at sourceforge.net/projects/pywin32/files/ and then build it as MSI file yourself. Therefore you need setuptools (only for building). Use the command "setup.py bdist_msi" to create a MSI installer in the "dist" directory.
The same procedure should work for all Windows-compatible packages.

Current easy_install can install the pre-build ".exe" installers silently, i.e.;
C:\Python27\Scripts\easy_install.exe pywin32-220.win32-py2.7.exe
will install pywin32.
This also enables possibility to remove using pip;
pip uninstall pywin32 -y
uninstalls pywin32

As said in a linked answer you can succeed with using easy_install if the installer was created with distutils.

If you want scripted automation of installs on Windows, look into AutoIt.

Related

How to make a debian package which includes several python packages

I want to create a debian package that when installed, it will install several python packages with pip. I can think of two ways:
install the python packages into a directory then make a debian package from that directory. But this will confuse the building host (such as its pip metadata), especially if the host already installed some of those packages.
make a debian package with all python packages, and during debian install and uninstall, run some scripts to install/uninstall the python packages. But this will need two more scripts to be maintained, and some place to hold all the python packages in the installed machine.
Any other solution and what's the best way to solve this problem?
In my opinion if you want to create a debian package you should avoid reference to external distribution systems.
Here there are the guidelines about the creation of python packages under debian.
EDIT: Sorry, I see now that the Debian wiki page about Python Packaging could be outdated. You could read:
the guide for pybuild
eventually the python page about building packages
If you want to create a meta package which depends on python-<packagename> in repositories, it is easy and I think you already know that. (if not, google equivs package). I assume you would like to have recent versions of the python packages installed or some packages are missing in debian repositories so the debian repositories will not be used.
pip is a good tool however you can break dependencies if you unistall a python package which my be required by another package which is installed by apt after your meta package. apt is your friend. You should be careful. To overcome this, my suggestions is to add the appropriate package names to your meta package's control file's Provides, Conflicts and Replaces fields whether you dynamically install the python packages via pip or bundle them in your main package. I quickly searched "bundling multiple debian packages into one package" and found no solution.
If you want to completely seperate your python packages from your system wide python packages, virtualenv is the best choice I know.
And if you want to build debian compliant packages using pip, stdeb can do that easily.
Moreover, As far as I remember, I saw some packages in Kali Linux (Debian based) dynamically installing python packages during install or during startup however Debian policies may not allow this kind of flexibility not to break dependencies (if you want to build an official package). I hope this answer guide you in the right direction.

Trouble installing scipy despite having python2.7 and numpy installed already

I'm having trouble installing scipy via the binaries provided at http://sourceforge.net/projects/scipy/files/scipy/
Double clicking on the mpkg file after mounting the dmg installer gives the following error:
"scipy 0.13.0 can't be installed on this disk. scipy requires System Python 2.7 to install"
However, I already have python 2.7 and numpy installed. The python 2.7 came default with OSX Lion, so I assume it is System Python. With other python modules, one normally can download the binary then run
python setup.py install
Is there a way to cd through the mpkg file and locate a setup.py? Any advice install via this dmg installer?
I know there are other ways to manage python modules, like port and brew. However, I already installed a bunch of packages through setup.py, and I couldn't figure out how to get port to recognize those packages (for example, it will try to reinstall python and numpy via port)
Thanks!
If you have Mavericks and XCode 5, then you'll have to install Command Line Tools manually from the Apple Developer Site. I found this helpful post
You've got a few misconceptions here.
With other python modules, one normally can download the binary then run python setup.py install
No, that's what you do with source packages.
Is there a way to cd through the mpkg file and locate a setup.py?
No. What's inside an mpkg are pkg files. Which are filled with xar archives filled with cpio archives. Inside there is the built version of SciPy—that is, the files that setup.py would have copied to your site-packages if you'd run it—not the source package.
But you can download the source package yourself.
Or, better, let pip (or easy_install, but pip is better) download and run the setup.py for you.
Any advice install via this dmg installer?
If it won't work, my advice would be to not use it, and instead install with pip.
This blog post explains it, but I'll give you the details relevant to you below.
I know there are other ways to manage python modules, like port and brew. However, I already installed a bunch of packages through setup.py, and I couldn't figure out how to get port to recognize those packages.
You can't. MacPorts will not touch your system Python; it builds its own separate Python 2.7, with a completely independent site-packages directory and everything else. You would have to reinstall everything for this second Python 2.7. And deal with the confusion of having two Python 2.7 installations on the same machine.
Don't do that unless you absolutely have to.
In fact, if you want to use Homebrew for anything (and you do, see below), uninstall MacPorts, unless you really need it for something.
So, here are the steps:
Uninstall MacPorts.
I assume you already have Xcode and its Command Line Tools.
I assume you already have Homebrew.
Install a Fortran compiler with brew install gfortran.
Lion's Python 2.7 comes with easy_install, but not pip. So sudo easy_install pip to fix that. While you're at it, I'd suggest sudo easy_install readline, because you'll want that for ipython, and it won't work right with pip.
Apple's pre-installed NumPy has to be upgraded, and rebuilt with Fortran support, to make SciPy work. Fix that with sudo pip install --upgrade --force-reinstall numpy.
If you want ipython, pandas, etc. sudo pip install each of them as well.
In case you're considering upgrading soon, the exact same steps worked for me with OS X 10.9.0, except for some extra work to get the Xcode 5 command line tools set up.

Working with many different modules in python

I am new to python just a few weeks back i started using python(Classic Noob-Disclaimer)
Now whenever i install a module by copying the unzipped folder in site-packages under Lib and running the source install by using "c:\python27\lib\site-packages\tweepy-1.2\setup.py install" in command prompt it installs without any errors.
But now when i make a python script (*.py)
and store it on the desktop it wont work
and it gives out an error "No module found"
but when i store it in the same folder as the source it works perfectly.
also if i open the IDLE GUI it also returns the same error.
But this doesnt happen with the win32com module which i use for TTS.
I missing something..but i cudnt find the answer to it.
Plz help me!
i need to use many of these modules..they work great differently but not together as the modules are always missing!
Copying an unzipped folder to site-packages does not install a Python package.
To install manually, unzip the package to a temporary directory, then run:
python setup.py install
in this directory, after that you can remove the directory.
To download and install a pure Python package automatically, run:
pip install tweepy
if you have pip installed.
The simplest way to install Python packages that have C extensions is to use binary installers (*.exe, *.msi files).
To avoid all this use VirtualEnv
Virtualenv is a tool to create isolated Python environments.
The basic problem being addressed is one of dependencies and versions, and indirectly permissions. Imagine you have an application that needs version 1 of LibFoo, but another application requires version 2. How can you use both these applications? If you install everything into /usr/lib/python2.7/site-packages (or whatever your platform's standard location is), it's easy to end up in a situation where you unintentionally upgrade an application that shouldn't be upgraded.
Or more generally, what if you want to install an application and leave it be? If an application works, any change in its libraries or the versions of those libraries can break the application.
Also, what if you can't install packages into the global site-packages directory? For instance, on a shared host.
The easiest way to install python packages is by using pip. First you need to install pip as explained here if you use windows. Then you can query some packages, from command line, for example
> pip search twitter
Then to install certain packages, just use pip something like this:
> pip install tweepy

Creating package installer in OS X - install Python, NumPy and other dependencies

I want to create a native Mac OS X package installer, the creation of the package is not really the problem, the real deal is the dependencies that have to get installed; I need to install Python, NumPy and Matplotlib (only if the required versions are not already installed).
I have heard really bad things about the Package Maker app, I've been reading a little and have already even found a nice tutorial although it is quite outdated. As a reference, here's Apple's reference guide.
I imagine I would have to use the uncompiled source provided from each of these three projects.
It would really help me to see the PackageMaker file that is used to create the official Python installer, if such file is available somewhere, please point me to it.
Anyway:
What would be the best way to do this? Is using a PackageMaker silly for this purpose? Any other literature that would help me?
Extra:
What would be the easiest way to test my installers?
I'm assuming that you want to install the packages that you mentioned because you are developing a Python application. Have you looked at PyInstaller? It "converts (packages) Python programs into stand-alone executables, under Windows, Linux, Mac OS X, Solaris and AIX", so you don't have to worry about what's installed on the target system.
And if you use PyInstaller, the "extra" would be easy. Simply copy the resulting executable to any other machine and test it out by executing it.
Something like /tmp/install.sh:
cd ~
curl -C - -O http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.7.tar.gz
tar -xzf virtualenv-1.7.tar.gz
cd ./virtualenv-1.7
python setup.py install
cd ~
rm virtualenv-1.7.tar.gz
rm -rd ./virtualenv-1.7
virtualenv myenvfolder
source myenvfolder/bin/activate
easy_install pip
pip install NumPy
pip install Matplotlib
And then:
chmod +x /tmp/install.sh;
/tmp/install.sh
Maybe you can use macports binary-packages or binary-archives?
and maybe fabric or puppet.
Puppet on OSX.
Macports is as simple as apt-get to use and takes care of all dependencies. By default macports installs to /opt/local so installs don't interfere with apple installs. Default is to compile from source. Some packages are big and have a lot of dependencies so compiling takes a lot of time and all the recourse on the machine. If you make a binary-archive you only have to compile ones pr machine arcithecture/osx-version. Then you only need to install macports and sett up a share with binary-archives. With fabric or puppet you can automate builds and distribution.
Then if you in the near future find out that you need pytable or numexpr it is as simple as: sudo port install py26-tables
and if other people need it to you can make binary-archive of it and put it on the share.
To install Python's latest version you can go here, and you can install NumPy and matplotlib directly in your terminal with these commands:
pip3 install matplotlib
pip3 install numpy

How to install easy_install in Python 2.7.1 on Windows 7

I have installed Python 2.7.1 on Windows 7, but I am unable to install easy_install.
Please help me.
I usually just run ez_setup.py. IIRC, that works fine, at least with UAC off.
It also creates an easy_install executable in your Python\scripts subdirectory, which should be in your PATH.
UPDATE: I highly recommend not to bother with easy_install anymore! Jump right to pip, it's better in every regard!
Installation is just as simple: from the installation instructions page, you can download get-pip.py and run it. Works just like the ez_setup.py mentioned above.
for 32-bit Python, the installer is here. after you run the installer, you will have easy_install.exe in your \Python27\Scripts directory
if you are looking for 64-bit installers, this is an excellent resource:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
the author has installers for both Setuptools and Distribute. Either one will give you easy_install.exe
Look for the official 2.7 setuptools installer (which contains easy_install). You only need to install from sources for windows 64 bits.
That tool is part of the setuptools (now called Distribute) package. Install Distribute. Of course you'll have to fetch that one manually.
http://pypi.python.org/pypi/distribute#installation-instructions
I recently used ez_setup.py as well and I did a tutorial on how to install it. The tutorial has snapshots and simple to follow. You can find it below:
Installing easy_install Using ez_setup.py
I hope you find this helpful.
The recommended way to install setuptools on Windows is to download ez_setup.py and run it. The script will download the appropriate .egg file and install it for you.
For best results, uninstall previous versions FIRST (see Uninstalling).
Once installation is complete, you will find an easy_install.exe program in your Python Scripts subdirectory. For simple invocation and best results, add this directory to your PATH environment variable, if it is not already present.
more details : https://pypi.python.org/pypi/setuptools
I know this isn't a direct answer to your question but it does offer one solution to your problem. Python 2.7.9 includes PIP and SetupTools, if you update to this version you will have one solution to your problem.

Categories