Friend doesn't has Python module installed is there a "workaround"? - python

I send mir friend a Python script with the module pytube.
But he hasn't installed the package so he couldn't run the script. It was not the big of a deal because easily installed pytube. But how can I prevent this? So if the script/program had more than one module but my friend doesn't want to install them all how can i "compile" the program that he doesn't need to install the modules?
I heard about Docker is this the right way or is there another way?

You can package your code or use docker indeed. Although, this costs more time then you want to spend on it probably.

Related

how to control if libraries are installed on the system in python

is there a way to create a function that check on the system if the python modules that are needed by the main program are installed and eventually install them automatically?
I searched a lot for something like this but i didn't found anything useful.
Thanks and sorry for the bad english.
The tool you are likely looking for is pip, it's not run as a part of a script but rather is used to install a script.
https://pip.pypa.io/en/stable/reference/
In addition if you wish to develop a script to install your script you can find documentation
http://marthall.github.io/blog/how-to-package-a-python-app/

Portable Python Script with Module

I'm new to using python modules.
I'm currently working on a python 2.7 script that will be deployed to many remote computers (which have python 2.7 on them). The problem is that the script needs to use a module, which I am not allowed to install on those computers.
I'm wondering if it is possible to include the module files in the same package as my script (possibly have them compiled first), and then have the script import the library from that local folder, thus achieving a "portable" script.
If that is possible, how would I go about doing that?
Specifics: I'm running 2.7.11 on Windows needing to use Paramiko.
I'm asking this question because the similar questions that I can find either do not answer mine, or expect me to be familiar with core python structures with which I am not. I also DON'T want to include the entirety of python and then install the module onto that, something I see is often called Portable Python. I just want to send my script and the module and nothing more.
Many thanks!
To install modules in a specific directory, you can try pip install module --target=.
By default python search for those modules in same directory as the script first, then, if not available, it will search for python install lib files.

Sharing Python file with non-standard modules?

Long time reader, first time OP.
I've written a program using 'Beautiful Soup' from the 'bs4' library and the 'requests' library (which is the most amazing thing, achieved in less than five minutes what I had failed to do in a week with urllib2), both of which I had to install (I'm using PyCharm CE).
If I'm sharing this file, what's the best way to make sure these modules are folded in with the package if I send it to someone? Or post it somewhere?
I'm running Python 3.5.2 in PyCharm CE
Thanks in advance!
You are probably asking about packaging and distributing python projects. That document describes how to package your project and upload it to PyPI.
If you only want to share a snippet of code, tell those who you are sending it to to install dependencies first via pip. Share the needed pip install <package> commands list.

Python: Handling modules

I wrote a program which uses a number of built in modules. The program is meant to be used by different persons on their systems. They dont have enough knowledge in python to install it when their system doesnt have the module needed to run the program. Is there any way of handling that.
Also I want to package the program as an executable in linux. It contains 3 py files and one text file only.
I think what you need is to create a debian package that handles the dependencies and the installation process.
I'm an Ubuntu user but this Complete Ubuntu Packaging Guide should help you get started. Good luck!
You can create an executable that contains your python modules and the python interpreter. You can use PyInstaller for creating such an executable.
I think the easiest way to achieve this on a debian distribution is to package your python application in a debian package. You can use this module to make life easier.

Run post-install script in a Python Egg (setuptools)

I have created a little Python egg (with setuptools) that I want to install in other machines of my LAN. I have even setup a server for the eggs and all (and the egg is properly downloaded and installed with easy_install -f http://myserver/eggrepository ) :-)
I would like to know if there's a way of running an script (bash or Python) when installing it with easy_install (version 0.6c11 and python2.6).
I have added a bash script to the package, and I'd like to be able to run it automatically (mainly to start some functionalities in the rcX.d levels, start running at startup, etc...) when the egg is installed. Right now I have to go to the /usr/local/lib/python2.6/dist-packages, find the folder where my egg was installed and run the bash script that is in said egg... But that solution is not very accurate and I'm sure it will give me problems if I change versions, paths, etc...
I've been reading and I found some posts saying it wasn't possible, but they are a bit old and maybe there's a way now... I also found others saying it was possible with distutils (which means that probably setuptools can do it too) but I haven't been able to find any suitable solution using setuptools.
Thank you in advance
Related:
How can I add post install scripts...
How to extend distutils with a simple post install script
Ok... I found a workaround...
python-packaging-custom-scripts
It's not as straight-forward as I would have liked, but well...
I can put the installation process in an sh file and then, since there's going to be a Python script in the user's path, I can call it from the bash script installing the package...

Categories

Resources