Is there any method using python libraries without installing? [duplicate] - python

This question already has answers here:
What is the purpose of "pip install --user ..."?
(9 answers)
Closed 8 months ago.
Since company's computer require admin right / presmission when installing anythings, is there any method using extend python libraries without installing (e.g. selenium, requests, beautifulsoup4, PyPDF2 and OpenPyXL).

Go to PyPI
find your package,
go to the Home at the left sidebar (most of them redirected to GitHub or GitLab)
then download the repository and install the package locally, something like this:
pip install /home/yourname/requests
pip install directory_of_setup.py
or use the package without installing it, import the source code to your project

Related

Calling pip package files from within pip package? (`No module named 'src.snnalgorithms'`) [duplicate]

This question already has answers here:
What is the use case for `pip install -e`?
(3 answers)
Closed 4 months ago.
Whilst in some_other_package, I am importing files from the snnalgorithms pip package. I received the error:
No module named 'src.snnalgorithms'. This is a valid error because that src.snnalgorithms file does not exist in the some_other_package project from which I was calling the pip package.
As a solution, I can make all the imports in the snn.algorithms pip package, relative to itself. Instead of:
from src.snnalgorithms.population.DUMMY import DUMMY
One could write:
from snnalgorithms.population.DUMMY import DUMMY
However, that implies that each time I want to run the code to briefly verify a minor change, or run the tests after a change, I will have to:
Upload the changes into the pip package.
Re-install the pip package locally to reflect the changes.
This significantly slows down development. Hence I was wondering are there more efficient solutions for this?
You can use editable mode for development mode
pip install -e . # Install package locally
From pip documentation:
Editable installs allow you to install your project without copying any files. Instead, the files in the development directory are added to Python’s import path. This approach is well suited for development and is also known as a “development installation”.
With an editable install, you only need to perform a re-installation if you change the project metadata (eg: version, what scripts need to be generated etc). You will still need to run build commands when you need to perform a compilation for non-Python code in the project (eg: C extensions).
Example
If you have project: some_other_package from which you call pip package snnalgorithms you can:
cd snnalgorithms
pip install -e .
cd ..
cd some_other_package
python -m src.some_other_package
Assuming you use the same conda environment for both packages, both packages will then be able to use your newest changes that have not even been published to pypi.org yet.

Get the requirements of a package in PyPI without installing it? [duplicate]

This question already has answers here:
Is there a way to list pip dependencies/requirements?
(10 answers)
Closed 4 years ago.
I need something like the following:
pip showrequirements tensorflow
This would return something that allows me to parse the names of the required packages and the required versions:
astor>0.6, tensorboard>1.0.11, etc.
pip is getting this information in some form during the install and download command. I can see where it's happening in the code... but before I hack my way to using pip's internal code, is there any easy API or existing library that can do this?
edit: I cannot install the package to see this, so pip show won't work. One (hacky) solution is parsing the output of pip download.
Thanks!
pip show <package_name>
will list the dependencies in the "Requires" section. See documentation.
Edit:
pip show only works for installed packages. For uninstalled packages, PyPI has a JSON API.
For example:
import json
import requests
package_name = 'tensorflow'
url = 'https://pypi.python.org/pypi/' + str(package_name) + '/json'
data = requests.get(url).json()
print(data['info']['requires_dist'])
So there used to be a --no-install flag in older version of pip, but no longer. pip show will show you the "Requires" property, but only for packages installed in your environment (system or in your venv), where it seems you wanna check out requirements before you install. So, sadly, I think there's not a nice way to accomplish what you're looking for.

How to install freetype and png for matplotlib [duplicate]

This question already has answers here:
Python (Win 10): Installing matplotlib requires packages "freetype" and "png"?
(4 answers)
Closed 6 years ago.
I'm trying to install freetype (and libpng) for using matplotlib.
I download the tar.gz files and decompress them.
But now i don't know what to do... Usually I use "python setup.py install" but there is no setup.py file.
For Windows, this is not a convenient way to install the dependencies. Use a package manager such as Anaconda.
See this answer for reference.

Installing Matplotlib in Openshift; freetypelib dependency [duplicate]

This question already has answers here:
ubuntu 14.04, pip cannot upgrade matplotllib
(9 answers)
Closed 8 years ago.
I am trying to install Matplotlib in a Python cartridge in Openshift with pip. it fails due to a dependency on freetypelib.
Is there a way to make Matplotlib work in that environment?
Check if libfreetype is installed (try "locate libfreetype"), if you find some output then you may have look at this post https://www.openshift.com/forums/express/is-libjpeg-available#comment-35344
If not install libfreetype. Let me know if you have any problems installing libfreetype

ImportError: No module named 'setuptools' [duplicate]

This question already has answers here:
Python 3: ImportError "No Module named Setuptools"
(22 answers)
Closed 8 years ago.
I'm new to python and have just installed the Python 3, I'm new to Python and I'm facing difficulties in importing a new library.
I'm trying to import tweepy-master library into python, I read the instructions given on their github page and did the "python setup.py install" command in command prompt (on windows 8), but I get the error which I've mentioned above,
Guys, please help, is there a separate library called setuptools which I need to install first?
It seems that you should use Setuptools, i.e. Distribute is deprecated:
Distribute is a deprecated fork of the Setuptools project. Since the
Setuptools 0.7 release, Setuptools and Distribute have merged and
Distribute is no longer being maintained. All ongoing effort should
reference the Setuptools project and the Setuptools documentation.
Obsolete
You should use distribute - a setuptools fork which "offers Python 3 support".
Installation instructions (according to documentation):
download python-distribute.org/distribute_setup.py (link is broken, obsolete information)
run it: python distribute_setup.py
It is recommended to install pip too: easy_install pip

Categories