Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

install python package at current directory

I am mac user, used to run pip install with --user, but recently after brew update, I found there are some strange things, maybe related.

Whatever I tries, the packages are always installed to ~/Library/Python/2.7/lib/python/site-packages

Here are the commands I run.

$ python -m site --user-site
~/Library/Python/2.7/lib/python/site-packages

$ pip install --user -r requirements.txt

$ PYTHONUSERBASE=. pip install --user -r requirements.txt

So what should be the problem?

I used for lambda zip packaging

Updates:

If using Mac OS X and you have Python installed using Homebrew (see Homebrew), the preceding command will not work. A simple workaround is to add a setup.cfg file in your /path/to/project-dir with the following content.

[install]
prefix=

https://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html

like image 693
Bill Avatar asked Oct 08 '18 04:10

Bill


People also ask

How do I install a package from a directory in Python?

To install a package that includes a setup.py file, open a command or terminal window and: cd into the root directory where setup.py is located. Enter: python setup.py install.

Does pip install in current directory?

pip install -e installs the source under the current working directory instead of under the environment directory #12.

How do I change where Python packages are installed?

CAUTION: Make sure you check option Add Python 3.5 to PATH . To change install location, click on Customize installation , then Next and enter C:\python35 (or another appropriate location) as the install location. If you didn�t check the Add Python 3.5 PATH option earlier, check Add Python to environment variables .


1 Answers

You can use the target (t) flag of pip install to specify a target location for installation.

In use:

pip install -r requirements.txt -t /path/to/directory

to the current directory:

pip install -r requirements.txt -t .
like image 117
Henry Woody Avatar answered Sep 21 '22 19:09

Henry Woody