Using a python package [duplicate] - python

This question already has answers here:
How to install Python packages from the tar.gz file without using pip install
(7 answers)
Closed 5 years ago.
I have downloaded the tar file of the Python geohash package
I import functions from this package to use them inside my python programs. It works completely fine, but only inside its own folder, where it is extracted.
If I intend to use this package in any other location, it doesn't simply import that package.
What should I do if I want to use it anywhere in my system ?
(the package is only available through this tarfile, not through pip/sudo apt-get)

Simply untar/unzip the file and make sure you have setup.py visible. From you command prompt in windows or linux. Go to the dir of the package which you just unzipped/untarred and dir/ls to make sure that setup.py is there and then do the following:
If you are using virtualenv:
/path-to-your-venv/venv/bin/python setup.py install
If you are not using virtualenv
python setup.py install

Related

Download PyPi package manualy with all dependencies (without PIP) [duplicate]

This question already has answers here:
How to install packages offline?
(12 answers)
Closed 5 months ago.
I am not able to use PIP on this device, so I need to install a module manually. The only problem is that I have to install like 30 dependencies of this module. I would have to download, unzip, include and install them all one by one.
Is there any faster way, like downloading a module with all its dependencies included?
If all requirements are pip packages, a quick solution might involve creating a lean python environment on another machine, installing the package using pip, and then copying over all of the resultant wheel files to the restricted machine either via SSH or another method.

How to install python wheel without using pip? [duplicate]

This question already has answers here:
Install python wheel file without using pip
(2 answers)
Closed 4 years ago.
I have downloaded .whl and trying to install it. Can you tell me the possible ways of installing wheel without using pip.
For tar.gz files, I executed python setup.py install and it installed my package.
How the same can be done for wheel when there is no setup.py file in it?
.whl: A compressed file like Zip Achieve.
How to install?
Install Winrar or other software that can extract compressed files.
Extract your .whl file in a safe folder.
Add that directory to your Path Variables.
Now everything is done.
It's bad practice to install a .whl file. You should use PIP.
Well, I recommend you to extract your .whl file in that folder where all Python modules are installed.

Packaging Your Python Code [duplicate]

This question already has answers here:
How to easily distribute Python software that has Python module dependencies? Frustrations in Python package installation on Unix
(2 answers)
Closed 5 months ago.
I wish to package a utility that I have created that depends on Pillow, a port of the Python Imaging Library. Is there a way to include Pillow in my own package or to automatically install Pillow upon running the setup script?
Python 3 mainly uses pip for installing packages. This is based off of setuptools and distribute. You would create the setup.py script with the requirement specified. The easiest way is to create a requirements file using pip. http://codeinthehole.com/writing/using-pip-and-requirementstxt-to-install-from-the-head-of-a-github-branch/
Command Line:
pip freeze > requirements.txt
setup.py
import setuptools
from pip.req import parse_requirements
requirements = [str(ir.req)
for ir in parse_requirements("requirements.txt", session=uuid.uuid1())
if ir.req is not None]
setuptools.setup(..., install_requires=requirements)
If you want to build an executable then the process if fairly similar to the standard setup.py file approach only you use cx_freeze.

Finding out the Python used to install the current package? [duplicate]

This question already has answers here:
Find full path of the Python interpreter?
(3 answers)
Closed 6 years ago.
Is there a way to programmatically find which Python version was used to install the current package?
If you have a package called mypackage and it has in its setup.py something like:
scripts = ["myscript.py"]
suppose install the package with easy_install or pip using a particular Python version, Python 2.x:
/usr/local/bin/python2.x setup.py install
Then in myscript.py, how can you find out that it was /usr/local/bin/python2.x that was used to install mypackage from myscript.py as opposed to some other Python version available on the system? I'd like to know the full path and not just the version info because I want to use /usr/local/bin/python2.x in my script.
Use sys.executable.
A string giving the absolute path of the executable binary for the
Python interpreter, on systems where this makes sense. If Python is
unable to retrieve the real path to its executable, sys.executable
will be an empty string or None.
Have a look at sys.version or sys.version_info.

How do I install modules in Python on Windows? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Installing modules in Python on Windows
The instructions in the documentation aren't helping. How do I install a module in Python?
If there is setup.py source file in module directory, run windows command line utility, change current directory to module directory and write
python setup.py install
make sure that python bin directory is in your system path variable
The same as everywhere, use easy_install. (Still it is somewhat more difficult to use under Windows because the cmd shell is far less powerful than bash)
You could try using pip

Categories

Resources