Installing Python packages from local file system folder to virtualenv with pip
I am pretty sure that what you are looking for is called --find-links
option.
You can do
pip install mypackage --no-index --find-links file:///srv/pkg/mypackage
How can I install packages using pip according to the requirements.txt file from a local directory?
This works for me:
$ pip install -r requirements.txt --no-index --find-links file:///tmp/packages
--no-index
- Ignore package index (only looking at --find-links
URLs instead).
-f, --find-links <URL>
- If a URL or path to an HTML file, then parse for links to archives.
If a local path or file://
URL that's a directory, then look for archives in the directory listing.
Installing Python packages from local file system folder with pip
--find-links=pyt/pkg
Find links in the directory, not in the patroni-1.4.4.tar.gz
archive.
Installing Python Packages From local File System
your command
pip install openpyxl c:\users\test\openpyxl-2.6.3.tar.gz
should be
pip install c:\users\test\openpyxl-2.6.3.tar.gz
as pip install
accepts local paths to .tar.gz
files directly.
Note that your pip
is also quite outdated. You might want to consider upgrading it to the newest version
Installing local packages with Python virtualenv --system-site-packages
Create the virtual environment without the --system-site-packages
switch. After the environment was created go to the folder the environment was created in. It should have a file pyvenv.cfg
. Edit this file. It has (among other text) a line
include-system-site-packages = false
Change this line to:
include-system-site-packages = true
Activate the environment. Module installations will now go to the virtual environment and the system site packages are visible too.
Install a Python package into a different directory using pip?
Use:
pip install --install-option="--prefix=$PREFIX_PATH" package_name
You might also want to use --ignore-installed
to force all dependencies to be reinstalled using this new prefix. You can use --install-option
to multiple times to add any of the options you can use with python setup.py install
(--prefix
is probably what you want, but there are a bunch more options you could use).
pip installing in global site-packages instead of virtualenv
Funny you brought this up, I just had the exact same problem. I solved it eventually, but I'm still unsure as to what caused it.
Try checking your bin/pip
and bin/activate
scripts. In bin/pip
, look at the shebang. Is it correct? If not, correct it. Then on line ~42
in your bin/activate
, check to see if your virtualenv path is right. It'll look something like this
VIRTUAL_ENV="/Users/me/path/to/virtual/environment"
If it's wrong, correct it, deactivate
, then . bin/activate
, and if our mutual problem had the same cause, it should work. If it still doesn't, you're on the right track, anyway. I went through the same problem solving routine as you did, which pip
ing over and over, following the stack trace, etc.
Make absolutely sure that
/Users/kristof/VirtualEnvs/testpy3/bin/pip3
is what you want, and not referring to another similarly-named test project (I had that problem, and have no idea how it started. My suspicion is running multiple virtualenvs at the same time).
If none of this works, a temporary solution may be to, as Joe Holloway said,
Just run the virtualenv's pip with its full path (i.e. don't rely on searching the executable path) and you don't even need to activate the environment. It will do the right thing.
Perhaps not ideal, but it ought to work in a pinch.
Link to my original question:
VirtualEnv/Pip trying to install packages globally
Related Topics
Googletrans Stopped Working with Error 'Nonetype' Object Has No Attribute 'Group'
How to Add Custom Methods/Attributes to Built-In Python Types
Error: (-215) !Empty() in Function Detectmultiscale
How to Zip Two Differently Sized Lists, Repeating the Shorter List
Convert Pandas.Series from Dtype Object to Float, and Errors to Nans
Why Do Integers in Database Row Tuple Have an 'L' Suffix
Making a String Out of a String and an Integer in Python
Find Shortest Matches Between Two Strings
How to Write a Python Module/Package
Run Function from the Command Line
Installing Python Packages from Local File System Folder to Virtualenv with Pip
How to Change the Figure Size of a Seaborn Axes or Figure Level Plot
Get List from Pandas Dataframe Column or Row
Execution of Python Code with -M Option or Not
Python Script to Do Something at the Same Time Every Day
Python MySQLdb Typeerror: Not All Arguments Converted During String Formatting