Create package with dependencies - python

Do you know how to create package from my python application to be installable on Windows without internet connection? I want, for example, to create tar.gz file with my python script and all dependencies. Then install such package on windows machine with python3.7 already installed. I tried setuptools but i don't see possibility to include dependencies. Can you help me?

Their are several Java tutorials on how to make installers that are offline. You have your python project and just use a preprogrammed Java installer to then put all of the 'goodies' inside of. Then you have an installer for windows. And its an executable.

Related

python how to build an exe file like scrapy.exe, pip.exe, virtualenv.exe in windows system?

I've found that a lot of python libraries that install have xxx.exe files, such as scrapy.exe, pip.exe, virtualenv.exe, etc. in the Scripts directory. How do they do that?I can't find relevant information, please guide me, thank you very much. By the way, python is installed in the Windows system.
You can use PyInstaller. On Windows it can compile to a single .exe file.
PyInstaller bundles a Python application and all its dependencies into
a single package. The user can run the packaged app without installing
a Python interpreter or any modules. PyInstaller supports Python 2.7
and Python 3.4+, and correctly bundles the major Python packages such
as numpy, PyQt, Django, wxPython, and others.
https://pyinstaller.readthedocs.io/en/stable/
According to the docs you will need Build Tools for Visual Studio 2017 which can be downloaded directly from here
Alternatively, you could install Anaconda which comes packed with pre-compiled binaries.
i get my answer, it set entry_points ={'console_scripts':['xx'='yy']} in setup.py, when install or package, it can auto build .exe in Scripts directory.

Why install Python packages

Why we have to install the python packages before using them?
I am currently working on a small python mysql program. What i tried to download the python connector module from mysql webpage and simply unzip it and place it in the same folder of my code.
And I can import the module properly.
So what is the meaning of installing those packages? Can I use those packages like matplotlib, numpy without installing them ?
Is it possible to have all the required packages installed on a folder so that i can move it to another computer and run my program with only CPython installed (I don't want to install any package on this computer)?
it's not that simple :-)
some packages have dependencies, you also need to download and extract their dependencies (you need pacakge x,and package x uses y) pakcage manager handles that
some package have some c code (they need to be compiled before use (ujson or postgres module) package manager handles that
when your share your code instead of sharing dependencies you simply add a file containing the list of dependencies (requirements.txt) and other user can simply install all dependencies using package manager
Installing a python package enables us to use it anywhere on our system. If we just place the package in the same directory as our script then it may well work, but only for scripts in that directory.
Some packages also rely on others to function properly, and the installation of a package may well install those pre-requisite packages for you. You may be able to do this manually, but you'd have to put them all in the same directory as your script every time you wanted to run it.
So installing the packages is the easiest way to use them.
You don't have to install them, and in some cases you wouldn't install them on your system; if you had split your code across two files and imported one file at the top of the other for example.
In fact, you don't really need install package on your system.
But if you install it, you can use these packages every where on your system.
Also, you can create a requirement.txt file to enable install all packages that you need on other computer. You can check this manual https://pip.pypa.io/en/stable/user_guide/#requirements-files

Create standalone applications with py2app by not using the system installation of Python on Mac?

I am using py2app to package a Python application to be used on other Mac computers. I am currently running OSX 10.7.5 and the system Python installation on my computer is Python 2.7.1. When I package the program with py2app, it works on my computer, but will not work on another computer - the error that comes up is it cannot locate a Python runtime.
From what I have read about this, it looks like my py2app build is using the system installation of Python on my computer and therefore will only create a semi-standalone application instead of a standalone application.
Also, I have seen that to fix this you need to package it with a separately downloaded Python. I have downloaded a separate Python and even tried to change my PYTHONPATH in my .bash_profile file, but cannot seem to get py2app to build with a different version of Python.
Can anyone point me in the right direction as to how to do this?
I have read other questions and wasn't able to find out how to do it in my case. If there is any other information you need to know to help, please let me know.
py2app builds the application bundle using the running version of python. To use the separate install of python you therefore have to make sure that py2app and the other libraries you use are available in that installation of Python, then use that installation to build the application.
For example:
$ /Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install py2app
$ .../bin/easy_install ...
$ /Library/Frameworks/Python.framework/Versions/2.7/bin/python setup.py py2app
The simplest way of handling this IMO is by utilizing MacPorts. You can download and install a standalone version of Python and just about any other package you might need.
Get macports: https://www.macports.org
sudo port install py27-py2app
sudo port select python python27
Now your standalone Python is the default, and py2app will run and bundle using that version of Python.

Installing Python modules for OpenERP 6.1 in Windows

I installed OpenERP 6.1 on windows using the AllInOne package. I did NOT install Python separately. Apparently OpenERP folders already contain the required python executables.
Now when I try to install certain addons, I usually come across requirements to install certain python modules. E.g. to install Jasper_Server, I need to install http2, pypdf and python-dime.
As there is no separate Python installation, there is no C:\Python or anything like that. Where and how do I install these python packages so that I am able to install the addon?
Thanks
Please check this link, may be helpful for you.
http://www.zbeanztech.com/blog/openerp-source-eclipse-under-windows
if you install the python package separately, then you have to add the bin path of the installed package to the system environment variable.
Good question..
Openerp on windows uses a dll for python (python26.dll in /Server/server of the openerp folder in program files). It looks like all the extra libraries are in the same folder, so you should be able to download the extra libraries to that folder and restart the service. (I usually stop the service and run it manually from the command line - its easier to see if there are any errors etc while debugging)
Let us know if you get it working!

Removing python and then re-installing on Mac OSX

I was wondering if anyone had tips on how to completely remove a python installation form Mac OSX (10.5.8) ... including virtual environments and its related binaries. Over the past few years I've completely messed up the installed site-packages, virtual-environments, etc. and the only way I can see to fix it is to just uninstall everything and re-install.
I'd like to completely re-do everything and use virtualenv, pip, etc. from the beginning.
On the other hand if anyone knows a way to do this without removing python and re-installing I'd be happy to here about it.
Thanks,
Will
Just for everyone else's reference. I found this in the Python documentation here:
Mac OS X 10.5 comes with Python 2.5.1 pre-installed by Apple. If you wish, you are invited to install the
most recent version of Python from the
Python website
(http://www.python.org). A current
“universal binary” build of Python,
which runs natively on the Mac’s new
Intel and legacy PPC CPU’s, is
available there.
What you get after installing is a
number of things:
* A MacPython 2.5 folder in your Applications folder. In here you find
IDLE, the development environment that
is a standard part of official Python
distributions; PythonLauncher, which
handles double-clicking Python scripts
from the Finder; and the “Build
Applet” tool, which allows you to
package Python scripts as standalone
applications on your system.
* A framework /Library/Frameworks/Python.framework,
which includes the Python executable
and libraries. The installer adds this
location to your shell path. To
uninstall MacPython, you can simply
remove these three things. A symlink
to the Python executable is placed in
/usr/local/bin/.
I removed these and the virtualenv directories. Then I re-installed everything and its working fine now.
You should be able to delete the packages you've installed from /Library/Python/2.*/site-packages/. I do not think any package installers will install by default to /System/Library, which should save you from needing to remove Python itself.
That said, you could also use virtualenv with --no-site-packages, and just ignore whatever packages you've installed system-wide without needing to remove them.

Categories