Python 3.6 pip failing to install when given a target directory
- [XX] are reporting a bug others will be able to reproduce and not asking a question. If you're not sure or want to ask a question do so on our Discourse: https://discourse.brew.sh
- [__] ran a
brewcommand and reproduced the problem with multiple formulae? If it's a problem with a single, official formula (not cask) please file this issue at Homebrew/homebrew-core: https://github.com/Homebrew/homebrew-core/issues/new. If it's abrew caskproblem please file this issue at https://github.com/caskroom/homebrew-cask/issues/new. If it's a tap (e.g. Homebrew/homebrew-php) problem please file this issue at the tap. - [XX] ran
brew updateand can still reproduce the problem? - [XX] ran
brew doctor, fixed all issues and can still reproduce the problem? - [XX] ran
brew configandbrew doctorand included their output with your issue?
To help us debug your issue please explain:
- What you were trying to do (and why)
From the brew-installed python3 package, I was trying to make use of the pip3 command to install a python package to a targeted directory. Command was:
pip3 install requests -t $(pwd)
- What happened (include command output)
Collecting requests
Using cached requests-2.18.4-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests)
Using cached idna-2.6-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests)
Using cached certifi-2018.1.18-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests)
Using cached urllib3-1.22-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests)
Using cached chardet-3.0.4-py2.py3-none-any.whl
Installing collected packages: idna, certifi, urllib3, chardet, requests
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python3.6/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/usr/local/lib/python3.6/site-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/usr/local/lib/python3.6/site-packages/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/usr/local/lib/python3.6/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python3.6/site-packages/pip/wheel.py", line 247, in move_wheel_files
prefix=prefix,
File "/usr/local/lib/python3.6/site-packages/pip/locations.py", line 153, in distutils_scheme
i.finalize_options()
File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/command/install.py", line 248, in finalize_options
"must supply either home or prefix/exec-prefix -- not both")
distutils.errors.DistutilsOptionError: must supply either home or prefix/exec-prefix -- not both
Note, this error is fully described in the last line: both home and prefix/exec-prefix were specified in this install. Now, I would identify that the issue is not in the distutils python package, but I believe it is in pip itself.
The version of pip is up to date.
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
The same version of pip was installed on the Linux box I checked, where the command succeeded (see the next section). Now, this could be an inherent problem with pip or perhaps a problem with how python3 + pip is configured for the brew install. I suspected if I reported this directly on the pip issues site, https://github.com/pypa/pip/issues, they would immediately want further information on the build and install processes used. Since I don't know those details, it would require information from brew support anyway.
- What you expected to happen
I expected pip to succeed. For contrast, I tested the same command on Linux and got this:
Collecting requests
Downloading requests-2.18.4-py2.py3-none-any.whl (88kB)
100% |████████████████████████████████| 92kB 1.7MB/s
Collecting chardet<3.1.0,>=3.0.2 (from requests)
Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB)
100% |████████████████████████████████| 143kB 4.2MB/s
Collecting urllib3<1.23,>=1.21.1 (from requests)
Downloading urllib3-1.22-py2.py3-none-any.whl (132kB)
100% |████████████████████████████████| 133kB 4.1MB/s
Collecting idna<2.7,>=2.5 (from requests)
Downloading idna-2.6-py2.py3-none-any.whl (56kB)
100% |████████████████████████████████| 61kB 5.4MB/s
Collecting certifi>=2017.4.17 (from requests)
Downloading certifi-2018.1.18-py2.py3-none-any.whl (151kB)
100% |████████████████████████████████| 153kB 4.5MB/s
Installing collected packages: chardet, urllib3, idna, certifi, requests
Successfully installed certifi-2018.1.18 chardet-3.0.4 idna-2.6 requests-2.18.4 urllib3-1.22
- Step-by-step reproduction instructions (by running
brewcommands)
pip3 install requests -t $(pwd)
- brew config output:
ORIGIN: https://github.com/Homebrew/brew
HEAD: 924c4af3de99f1f7dfef3acdcb03de2bcc9af0ee
Last commit: 29 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: fba87cb5f5c7e926ce68434a40b5ab4ed5259cec
Core tap last commit: 2 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_RUBY_WARNINGS: -W0
CPU: octa-core 64-bit haswell
Homebrew Ruby: 2.3.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/bin/ruby
Clang: 9.0 build 900
Git: 2.14.3 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.54.0 => /usr/bin/curl
Perl: /usr/bin/perl
Python: /usr/local/bin/python => /usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/bin/python3.6
Ruby: /usr/local/bin/ruby => /usr/local/Cellar/ruby/2.5.0/bin/ruby
Java: 1.8.0_162, 1.8.0_151
macOS: 10.12.6-x86_64
Xcode: 9.2
CLT: 9.2.0.0.1.1510905681
X11: N/A
MacPorts/Fink: /opt/local/bin/port
- brew doctor output
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: Putting non-prefixed coreutils in your path can cause gmp builds to fail.
Warning: You have MacPorts or Fink installed:
/opt/local/bin/port
This can cause trouble. You don't have to uninstall them, but you may want to
temporarily move them out of the way, e.g.
sudo mv /opt/local ~/macports
Warning: Homebrew's sbin was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting the PATH for example like so
echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile
This is limitation of Python's distutils. You need to create venv.
If it's a problem with a single, official formula (not cask) please file this issue at Homebrew/homebrew-core: https://github.com/Homebrew/homebrew-core/issues/new.
So this is filed in the wrong repository.
Also, note this is a duplicate of https://github.com/Homebrew/brew/issues/837, which we're not planning on attempting to fix, but we'd review a PR if someone comes up with a fix.