Python - download packages from own server - python

I wonder how can I force setup.py install command to download packages (via pip) from my server. I can get pip my server address but every dependecies are downloaded from pip server.
Maybe solution is pip.ini/pip.conf?
Tomek

From the docs, you can use the:
--use-mirrors --mirrors <url>
flag in pip to specify which mirror to use.
From command line, you can also speicify mirrors. For example:
pip install -i http://d.pypi.python.org/simple $PACKAGE

Related

Downloading a python library and installing it locally from the computer

Have a bit of an issue here. I haven't got admin access to my work computer (working on getting it) so I can't install packages. IT has given me a temporary Admin password but Admin doesn't have internet access.
So I have to download the library itself. I went to
https://github.com/scikit-learn-contrib/imbalanced-learn.git
and downloaded "imbalanced-learn-master.zip"
My question now is - how do I install this on my computer locally? I can "Run as Administrator" anything from the command prompt
First. How You install packages.
If from command line then you can use --user switch
then command will look
pip install --user imbalanced-learn
Other option is to install from wheel file. So download: https://files.pythonhosted.org/packages/eb/aa/eba717a14df36f0b6f000ebfaf24c3189cd7987130f66cc3513efead8c2a/imbalanced_learn-0.6.1-py3-none-any.whl
and then
pip install imbalanced_learn-0.6.1-py3-none-any.whl
or without admin privileges
pip install --user imbalanced_learn-0.6.1-py3-none-any.whl
Third option is to install from source (as you asked). You need to unpack zip file and in terminal go to main folder (with setup.py) and then
pip install .
But you also need to install package dependencies. You can found them in setup.py
For current master it is
INSTALL_REQUIRES = [
'numpy>=1.11',
'scipy>=0.17',
'scikit-learn>=0.22',
'joblib>=0.11'
]
You need to use the pip (or any package installer) through your corporate proxy.
pip install package_name --proxy=http://corporate-proxy.company_website.com:8080

Setting up the path so AWS cli works properly

I installed AWSCLI by using:
pip install --upgrade --user awscli
Now if I type aws configure in the cmd I get: 'aws' is not recognized as an internal or external command...
I'm pretty sure the path needs to be set correctly. I know how to go into the environment variables to set the path, but I don't know WHAT to set the path to because I don't see where awscli is installed. By the way, I already have boto3 installed and I'm able to import that just fine.
I should also mention I'm setting this up in windows.
Hi I just had the same problem, and I managed to solve this!
I'm using python 3.7.0 and pip version 18.
I installed awscli using
pip install --upgrade --user awscli
but it is not added in PATH, and I have no idea how to find it.But when I decided to delete it, running
pip uninstall awscli
it told me that
Uninstalling awscli-1.15.65:
Would remove:
c:\users\riz\appdata\roaming\python\python37\scripts\aws
c:\users\riz\appdata\roaming\python\python37\scripts\aws.cmd
c:\users\riz\appdata\roaming\python\python37\scripts\aws_bash_completer
c:\users\riz\appdata\roaming\python\python37\scripts\aws_completer
c:\users\riz\appdata\roaming\python\python37\scripts\aws_zsh_completer.sh
c:\users\riz\appdata\roaming\python\python37\site-packages\awscli-1.15.65.dist-info\*
c:\users\riz\appdata\roaming\python\python37\site-packages\awscli\*
So I know the file was installed in
c:\users\riz\appdata\roaming\python\python37\scripts\aws
you just need to add this to PATH! Good Luck!
I had the same problem. http://docs.aws.amazon.com/cli/latest/userguide/awscli-install-windows.html says that you should set the path to %USERPROFILE%\AppData\Local\Programs\Python\Python36\Scripts if you use pip, but the path for me was actually %USERPROFILE%\AppData\Roaming\Python\Scripts. You can search for aws.cmd to find where it was actually installed. Just add that directory to your path environmental variable. I'm using Python 2.7 so that might explain the difference.
There are two ways to do it:
1. upgrade existing aws-cli
2. do a clean install
here are the steps to do a clean install:
remove any existing aws-cli rpms's: pip remove aws-cli
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
pip -y install unzip
unzip awscli-bundle.zip
./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
aws --version
I had the same problem when trying to install awscli on windows 10 x64. I was installing awscli using command below (which recommended from the following guide (Installing the AWS CLI):
pip3 install awscli --upgrade --user
But after I run that command, I still can't run aws --version command. It said that aws is not recognized. So after some triage, the only works and easy way to install awscli is download the awscli is using the msi installer provided by Amazon itself:
https://docs.aws.amazon.com/cli/latest/userguide/install-windows.html
Just run, install, no extra configuration needed, restart your command line, and it works like charm.

running sudo pip install times out

I'm having an issue when trying to run sudo pip install ... as it timesout when ever I try to install a package that way. I'm behind a proxy (OS is RHEL7) and I setup the proxy by running:
export http_proxy=http://proxy:8099
export https_proxy=http://proxy:8099
if I do a pip install ..., that downloads but can't install because I'm not running as sudo. If I do sudo pip install ..., the Collecting ... part keeps giving me a network unreachable error.
Try downloading the *.whl file and install the package passing the filename as parameter to pip. For example, the following line is trying to install BeautifulSoup.
python -m pip install beautifulsoup4-4.5.3-py2-none-any.whl
Also, you may download the compressed file, extract it and run the setup.py file inside of that folder.
tar -xzvf beautifulsoup4-4.5.3.tar.gz
cd beautifulsoup4-4.5.3
python setup.py install
Wanted this answer to be a comment, but still. You have:
export https_proxy=http://proxy:8099
which is using http, but it should be https actually. Try editing this line.
In addition to what the others have posted, I found this link. It seems that there is a known problem with pip and proxies. You also may have to use the --proxy=<proxy address> flag with your pip command.

python pip - install from local dir

I have to download a git python repo and install since the pypi version is not updated.
Normally I would do this:
pip install mypackage
pip install mypackage[redis]
Now I have the repo cloned in the following folder:
/opt/mypackage
So how do I install the below while ensuring that I use the local version, not the pypi version.
pip --flag /opt/mypackage install mypackage
pip --flag /opt/mypackage install mypackage[redis]
There are the pip flags available and I don't see how to accomplish :
Commands:
install Install packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
search Search PyPI for packages.
wheel Build wheels from your requirements.
help Show help for commands.
General Options:
-h, --help Show help.
--isolated Run pip in an isolated mode, ignoring environment variables and user configuration.
-v, --verbose Give more output. Option is additive, and can be used up to 3 times.
-V, --version Show version and exit.
-q, --quiet Give less output.
--log <path> Path to a verbose appending log.
--proxy <proxy> Specify a proxy in the form [user:passwd#]proxy.server:port.
--retries <retries> Maximum number of retries each connection should attempt (default 5 times).
--timeout <sec> Set the socket timeout (default 15 seconds).
--exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup.
--trusted-host <hostname> Mark this host as trusted, even though it does not have valid or any HTTPS.
--cert <path> Path to alternate CA bundle.
--client-cert <path> Path to SSL client certificate, a single file containing the private key and the certificate in PEM format.
--cache-dir <dir> Store the cache data in <dir>.
--no-cache-dir Disable the cache.
--disable-pip-version-check
All you need to do is run
pip install /opt/mypackage
and pip will search /opt/mypackage for a setup.py or pyproject.toml, build a wheel, then install it.
The problem with using the -e flag for pip install as suggested in the comments and this answer is that this requires that the original source directory stay in place for as long as you want to use the module. It's great if you're a developer working on the source, but if you're just trying to install a package, it's the wrong choice.
Alternatively, you don't even need to download the repo from Github first. pip supports installing directly from VCS (version control systems) repos like git using a variety of protocols including HTTP, HTTPS, and SSH, among others. See the docs for examples.
To see all of the pip install command options, run
pip install --help
You were looking for help on installations with pip. You can find it with the following command:
pip install --help
Running pip install -e /path/to/package installs the package in a way, that you can edit the package, and when a new import call looks for it, it will import the edited package code. This can be very useful for package development. Only use the -e flag if you need to edit the package's source code.
Further information about local installs and the -e/--editable flag of pip and its caveats is available in the official pip "Local project installs" and setuptools "Development Mode (a.k.a. "Editable Installs)" documentation chapters. The latter also lists a range of limitations of editable installs.
This command helped me.
pip install path/to/dir --use-feature=in-tree-build

Breaking 'pip install' to smaller steps, so I can edit the package before it is installed

My familiarity with pip ends up with the ability to do: 'pip install', 'pip uninstall', and 'pip list' - with the name of the package I want to install as the single argument.
This limited knowledge carried me so far, to the extent I'm able to install most of the simple packages, and sometime, when I'm luck, I'm even able to install packages that requires compilation. This is all magic for me.
I'm now facing a situation where I need to do a little bit of editing to the C file (side note: this seems to be a known workaround for the 'netifaces' package - which everyone seems to be in peace with. By itself this is an amazing phenomena).
So I would like to break the installation into smaller steps:
Download the egg file (I've figured out this one: pip install --download).
Unzip or otherwise unpackage the package file, to the point I can edit individual
Do my custom modification.
Do the build
Do the installation.
Other than step #1, I don't know how to proceed.
Modern pip (Since 1.10)
Use pip download:
pip download mypackage
pip 1.5 - 1.9
Use pip install -d
pip install -d . --allow-external netifaces --allow-unverified netifaces netifaces
tar xzf netifaces-0.8.tar.gz # Unpack the downloaded file.
cd netifaces-0.8
Now do your modifications and continue:
pip install .
Old pip (Before 1.5)
Install the package with --no-install option; with --no-install option, pip downloads and unpacks all packages, but does not actually install the package.
pip install --no-install netifaces
Change to the build directory. If you don't know where is the build directory, issue above command again, then it display the location.
cd /tmp/pip_build_falsetru/netifaces
Do the custom modification.
Install the package using pip install . (add --no-clean option if you want keep the build directory) or python setup.py install.
sudo pip install --no-clean .
First, download the source to 0.8 from the author's home page (there's no direct download link from PyPI, for some reason). Go to the directory where you downloaded it and unzip it:
tar zxvf netifaces-0.8.tar.gz
Enter the netifaces-0.8/ directory and edit netifaces.c with your favorite editor. Save the file. Then, build the module:
python setup.py build
and install it:
sudo python setup.py install
To test, first leave the directory, then start your python interpreter and import netifaces to see if it works.
Good luck!
Download your selected package, extract the files,edit what you want. Then, open the directory with your terminal\cmd and run:
python setup.py install
Depending on your os you might need to add a little sudo to the beginning of this command (if you intend to install globally on a Unix machine)
You could just download the source from pypi, edit it and use setup.py buid, setup.py install

Categories