Why does Pip disregard configured repository with nested dependencies? - python

Problem
Let us say I have a completely empty Python+Pip+R (pip 19.3.1) environment on a Linux machine and I want to install the package rpy2 with pip. Since I am behind a corporate firewall I configure pip to use a private repository.
[global]
index-url = http://private.com/artifactory/api/pypi/PyPI/simple
trusted-host = private.com
Now I execute pip install rpy2 and I will get back the following error:
Couldn't find index page for 'cffi'
Download error on https://pypi.python.org/simple/
So pip tries to resolve the nested dependency by looking and installing cffi from the official PyPi repository. It completely ignores the repo I have configured.
When I run pip install cffi && pip install rpy2 one after another everything works as expected.
Here is the full error output:
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-8vuadu93/rpy2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-8vuadu93/rpy2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-8vuadu93/rpy2/pip-egg-info
cwd: /tmp/pip-install-8vuadu93/rpy2/
Complete output (25 lines):
Download error on https://pypi.python.org/simple/cffi/: [Errno -2] Name or service not known -- Some packages may not be found!
Couldn't find index page for 'cffi' (maybe misspelled?)
Download error on https://pypi.python.org/simple/: [Errno -2] Name or service not known -- Some packages may not be found!
No local packages or working download links found for cffi>=1.13.1
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-8vuadu93/rpy2/setup.py", line 183, in <module>
'rinterface_lib/R_API_eventloop.h']}
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 128, in setup
_install_setup_requires(attrs)
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 123, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 513, in fetch_build_eggs
replace_conflicting=True,
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 774, in resolve
replace_conflicting=replace_conflicting
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1057, in best_match
return self.obtain(req, installer)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1069, in obtain
return installer(requirement)
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 580, in fetch_build_egg
return cmd.easy_install(req)
File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 692, in easy_install
raise DistutilsError(msg)
distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('cffi>=1.13.1')
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Question
Is this a bug in Pip, a specific problem with rpy2 or am I missing something?
Updates
Running the following commands gives me the same error:
pip install rpy2 --no-index --find-links http://private.com/artifactory/api/pypi/PyPI/simple
pip install rpy2 --index-url http://private.com/artifactory/api/pypi/PyPI/simple
I used -vvv and it seems like the problem occurs somewhere inside of setuptools
Solution
The package rpy2 uses setuptools which again uses easy_install.py. It also works with an index_url variable. But it gets the value not from pip.config but distutils.cfg.
I identified all Python versions I have installed with find / -name "distutils". Then I added the a distutils.cfg with the following content to each of these directories:
[easy_install]
index_url = blablabla
And now it works, I execute pip install rpy2 and all missing requirements are installed in one go

I believe it could be caused by the fact that cffi is listed as setup_requires in rpy2's setup.py. Most likely because cffi is required to build the project itself before it can be installed. This kind of build dependencies are not handled by pip directly, so its index-url option has no effect.
The solution is to tell setuptools about the alternative index in a distutils configuration file
[easy_install]
index_url = https://my.index-mirror.com
References:
"Controlling setup_requires" in pip's documentation
setuptools, easy_install, and a custom pypi server
distutils configuration file

Related

Tensorboard Install Fails while Installing Tensorflow in Conda Environment on M1 Mac

I'm trying to install tensorflow on an M1 Mac. I've been trying to follow this tutorial to install the pre release version of tensorflow for Mac.
From the pre-release repo:
This pre-release delivers hardware-accelerated TensorFlow and TensorFlow Addons for macOS 11.0+. Native hardware acceleration is supported on M1 Macs and Intel-based Macs through Apple’s ML Compute framework.
The pre-release requires Python 3.8, so that's what I set up my conda environment with.
The tutorial above tries to install a previous version of tensorflow for M1 Mac, so I adjusted the commands to use the version of tensorflow for M1 Mac that I've downloaded.
I've been trying to do this install in a virtual environment using Miniforge, as it is what multiple tutorials have recommended for M1 Mac installs. From the Miniforge repo:
This repository holds a minimal installer for Conda specific to conda-forge. It is comparable to Miniconda
When I get to the step to install tensorboard, pip install tensorboard, the install gets as far as:
Building wheels for collected packages: grpcio
Building wheel for grpcio (setup.py) ... error
The errors go on for many pages, but here is the last block:
Traceback (most recent call last):
File "/private/var/folders/nq/2mtcpkp51dd149_bnk1g1t340000gn/T/pip-install-ze40tjy3/grpcio_c9426269e87d4673a65bd63bd6af18ee/src/python/grpcio/commands.py", line 282, in build_extensions
build_ext.build_ext.build_extensions(self)
File "/Users/bitflow/miniforge3/envs/conda-tf-venv/lib/python3.8/distutils/command/build_ext.py", line 449, in build_extensions
self._build_extensions_serial()
File "/Users/bitflow/miniforge3/envs/conda-tf-venv/lib/python3.8/distutils/command/build_ext.py", line 474, in _build_extensions_serial
self.build_extension(ext)
File "/Users/bitflow/miniforge3/envs/conda-tf-venv/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 208, in build_extension
_build_ext.build_extension(self, ext)
File "/Users/bitflow/miniforge3/envs/conda-tf-venv/lib/python3.8/distutils/command/build_ext.py", line 528, in build_extension
objects = self.compiler.compile(sources,
File "/private/var/folders/nq/2mtcpkp51dd149_bnk1g1t340000gn/T/pip-install-ze40tjy3/grpcio_c9426269e87d4673a65bd63bd6af18ee/src/python/grpcio/_parallel_compile_patch.py", line 58, in _parallel_compile
multiprocessing.pool.ThreadPool(BUILD_EXT_COMPILER_JOBS).map(
File "/Users/bitflow/miniforge3/envs/conda-tf-venv/lib/python3.8/multiprocessing/pool.py", line 364, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "/Users/bitflow/miniforge3/envs/conda-tf-venv/lib/python3.8/multiprocessing/pool.py", line 771, in get
raise self._value
File "/Users/bitflow/miniforge3/envs/conda-tf-venv/lib/python3.8/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/Users/bitflow/miniforge3/envs/conda-tf-venv/lib/python3.8/multiprocessing/pool.py", line 48, in mapstar
return list(map(*args))
File "/private/var/folders/nq/2mtcpkp51dd149_bnk1g1t340000gn/T/pip-install-ze40tjy3/grpcio_c9426269e87d4673a65bd63bd6af18ee/src/python/grpcio/_parallel_compile_patch.py", line 54, in _compile_single_file
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/private/var/folders/nq/2mtcpkp51dd149_bnk1g1t340000gn/T/pip-install-ze40tjy3/grpcio_c9426269e87d4673a65bd63bd6af18ee/src/python/grpcio/commands.py", line 265, in new_compile
return old_compile(obj, src, ext, cc_args, extra_postargs,
File "/Users/bitflow/miniforge3/envs/conda-tf-venv/lib/python3.8/distutils/unixccompiler.py", line 120, in _compile
raise CompileError(msg)
distutils.errors.CompileError: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Users/bitflow/miniforge3/envs/conda-tf-venv/bin/python3.8 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/nq/2mtcpkp51dd149_bnk1g1t340000gn/T/pip-install-ze40tjy3/grpcio_c9426269e87d4673a65bd63bd6af18ee/setup.py'"'"'; __file__='"'"'/private/var/folders/nq/2mtcpkp51dd149_bnk1g1t340000gn/T/pip-install-ze40tjy3/grpcio_c9426269e87d4673a65bd63bd6af18ee/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/nq/2mtcpkp51dd149_bnk1g1t340000gn/T/pip-record-t11k_i1o/install-record.txt --single-version-externally-managed --compile --install-headers /Users/bitflow/miniforge3/envs/conda-tf-venv/include/python3.8/grpcio Check the logs for full command output.
There was an earlier step to install grpcio, that claimed to work successfully, that used the following command:
pip install --upgrade -t “$env/lib/python3.8/site-packages/” --no-dependencies --force "$libs/grpcio-1.33.2-cp38-cp38-macosx_11_0_arm64.whl"
I tried to import tensorflow in python, without having tensorboard installed, and the only error appears to be that tensorboard is not yet installed. This gives me some confidence that the rest of the set up went okay.
>>> import tensorflow
WARNING:root:Limited tf.compat.v2.summary API due to missing TensorBoard installation.
WARNING:root:Limited tf.compat.v2.summary API due to missing TensorBoard installation.
WARNING:root:Limited tf.compat.v2.summary API due to missing TensorBoard installation.
WARNING:root:Limited tf.summary API due to missing TensorBoard installation.
I double checked, and retried, the step around installing grpcio before trying again. While grpcio seemed to install okay again, the tensorboard install still failed in the same way.
I'd really appreciate any help that could be offered to solve this.
I ended up referencing a lot of different materials to try get my solution working. There are two main materials which I can credit with my success:
The "Troubleshooting and common errors" section of Clayton Pilat's tutorial on how to set up tensorflow on an M1 Mac
grpcio-1.33.2-cp38-cp38-macosx_11_0_arm64.whl is not a supported wheel on this platform.
For some reason the version of Python that you download from the website for MacOS doesnt seem to like these files, so uninstall your current version of Python (if you dont know how to do that click here).
And then install the Python from xcode by pasting this into your terminal.
xcode-select --install
The environment variables and flags that github user Tenzer used to install grpcio
I had to set a few environment variables to get it to work:
GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1
GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1
to make the installation process use the libraries I've already got on the system, and then the following to point it at OpenSSL installed via Homebrew:
CFLAGS="-I/opt/homebrew/opt/openssl/include"
LDFLAGS="-L/opt/homebrew/opt/openssl/lib"
I was focused on trying to fix the issue with the building of grpcio during the tensorboard install. To that end, following the above links, and throwing in a restart for the fun of it, I was finally able to install tensorboard.
Now, if I am using Python in my conda environment, I can import tensorflow and it works just fine!

pip install produces the following error on mac: error: command 'gcc' failed with exit status 1

So I tried to install a package from PyPI with the following command:
sudo pip3 install switcheo
But it fails to install the package in the end.
Error checking for conflicts.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2584, in version
return self._version
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2691, in __getattr__
raise AttributeError(attr)
AttributeError: _version
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 503, in _warn_about_conflicts
package_set, _dep_info = check_install_conflicts(to_install)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/operations/check.py", line 108, in check_install_conflicts
package_set, _ = create_package_set_from_installed()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/operations/check.py", line 47, in create_package_set_from_installed
package_set[name] = PackageDetails(dist.version, dist.requires())
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2589, in version
raise ValueError(tmpl % self.PKG_INFO, self)
ValueError: ("Missing 'Version:' header and/or METADATA file", Unknown [unknown version] (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages))
Installing collected packages: scrypt, neocore, switcheo
scrypt-1.2.1/libcperciva/crypto/crypto_aes.c:6:10: fatal error: 'openssl/aes.h' file not found
#include <openssl/aes.h>
^~~~~~~~~~~~~~~
1 error generated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-install-b6w97vc0/scrypt/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/tmp/pip-record-qvammwag/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-install-b6w97vc0/scrypt/
This is the full output in the terminal after running the pip install line.
I found some solutions for linux, but there are not a lot of posts here for mac users.
I dealt with this problem for a while while trying to install another library that relies on openssl in a MacOS virtual env.
Mac has deprecated openssl in favor of their own SSL. So what you need to do is:
brew install openssl
or if it is already installed,
brew reinstall openssl
Now you need to to change the LD and CPP Flags. Refer to the openssl reinstall dialog. Should tell you where the commands!
openssl is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.
If you need to have openssl first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
For compilers to find openssl you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
For pkg-config to find openssl you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
You're either missing the OpenSSL package, or your system can't find where it is on your system. Try brew install openssl.
A more detailed answer openssl/aes.h' file not found on Mac
after spending hours, i successfullly installed.
If you are using mac and if you are using anaconda
please open python terminal from anaconda
then paste the following link and click enter.
conda install -c conda-forge/label/gcc7 wordcloud
if you need more clarity please visit following link
https://anaconda.org/conda-forge/wordcloud

Permission error with pip Python 3

I am using Python 3 on Mac OS X. Everything was perfect, I used to install packages like this:
pip install somePackage
But IDLE stopped working so I had to re-install it. After that, when I ran pip, I got pip is not defined so I had to install pip. Now, every time I try to install a package using pip, I get this error:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 784, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 377, in move_wheel_files
clobber(source, dest, False, fixer=fixer, filter=filter)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 287, in clobber
ensure_dir(dest) # common for the 'include' path
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 1] Operation not permitted: '/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pygame'
I thought it may be from the version so I updated it. Now, whenever I run pip install something I get this error:
Command "/usr/bin/python -u -c "import setuptools, tokenize;file='/private/var/folders/bc/hwpn9sqn5352xcbst0p89snm0000gn/T/pip-build-hSNyxK/termcolor/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /var/folders/bc/hwpn9sqn5352xcbst0p89snm0000gn/T/pip-U3ZtNq-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/bc/hwpn9sqn5352xcbst0p89snm0000gn/T/pip-build-hSNyxK/termcolor/
I can't even delete a package - when I run pip uninstall something I get this error:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/uninstall.py", line 76, in run
requirement_set.uninstall(auto_confirm=options.yes)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 346, in uninstall
req.uninstall(auto_confirm=auto_confirm)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
copy2(src, real_dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
copystat(src, dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/var/folders/bc/hwpn9sqn5352xcbst0p89snm0000gn/T/pip-OQKY_a-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'
My pip version is :
pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)
I am using Mac 10.12.6
How can I fix this?
The permission error you're seeing is due to the fact that your site-packages directory (where pip is trying to install to) is protected and owned by an administrator.
Where is the site packages directory
It depends on your Python distribution. That's why I asked for you to include the output of the $ which python command (from the command line), and the >>> import site; site.getsitepackages() command (from Python). These will help you figure out where your site packages directory is. Also, running pip -v will print the directory to which pip is trying to install.
It is important to note that Macs come with a system version of Python. You should not install any packages accessible to this system version of Python, because it is used by the system and you can potentially interfere with its normal workings and/or install malicious versions of packages that will do bad things when the system uses that Python (e.g., if someone made a nasty egg and called it "os" and put it in the site-packages directory for your system Python, then the next time the system python version ran "import os" it would import the nasty egg.)
Why overriding with sudo pip install is not a good solution
While running your pip install command as sudo would probably solve the problem, this is a short-term fix that is very bad for the reasons mentioned in my comment in #Nenand's answer - running pip install X downloads the egg for X from the internet, and runs python setup.py build && python setup.py install on whatever happens to be in the setup.py. While it's easy to be lulled into complacency because, hey, it works!, it's also naive to trust strangers on the internet (and let's face it, the people who make pip packages are strangers to you).
EDIT: I didn't even think of this, but there is also the potential that you mis-type a library, or guess the wrong name, and end up with one you REALLY didn't want (typosquatting). See this BleepingComputer article on typosquatting pip packages.
The proper solution
The proper solution is to figure out why your site-packages directory is protected, and either fix its permissions, or change the site-packages directory pip is using.
I suspect the reason you're seeing this permissions error is that pip is trying to install to the system Python's site-packages directory, which is owned by root for a good reason. The system Python is located at /usr/bin/ and its site-packages directory is located at the following directories:
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages'
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/site-python'
'/Library/Python/2.7/site-packages'
My advice, in this case, is to install Python using Homebrew, Python.org, or Canopy, which will keep your snakes in separate cages and will leave the system Python alone. On my system, python is the system python, python2 is Python version 2, and python3 is Python version 3. This also makes it more clear which version I'm using. I also do not have a pip command - not on my path - so I can't accidentally install something to my system Python. I have to explicitly call pip2 or pip3. Using Homebrew Python will do all of this for you, so that's my most-favored recommendation of the many Python distributions available.

Pip install --target=. Alfred-Workflow gives an error

I am trying to install a python library on macOS following through these instructions.
However I get an error every time I run this command : pip install --target=. Alfred-Workflow
And I always get this error for running it :
pip install --target=. Alfred-Workflow
Collecting Alfred-Workflow
Installing collected packages: Alfred-Workflow
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/usr/local/lib/python2.7/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/python2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 247, in move_wheel_files
prefix=prefix,
File "/usr/local/lib/python2.7/site-packages/pip/locations.py", line 153, in distutils_scheme
i.finalize_options()
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 264, in finalize_options
"must supply either home or prefix/exec-prefix -- not both"
DistutilsOptionError: must supply either home or prefix/exec-prefix -- not both
I tried googling and searching for this but still can't figure it out. Thank you for any help.
This question answers that (I found it when googling for the last line of your error message).
First I also got the same error message as you did, but after doing this:
$ echo "[install]
prefix=" > ~/.pydistutils.cfg
It works:
$ pip install --target=. Alfred-Workflow
Collecting Alfred-Workflow
Installing collected packages: Alfred-Workflow
Successfully installed Alfred-Workflow-1.24
Important note: it breaks normal pip install commands, so you need to rm ~/.pydistutils.cfg afterward.
I have a similar error installing python modules using pip with -t(--target) option.
The pip log show the next message:
Complete output from command /usr/bin/python -c "import setuptools, tokenize;file='/tmp/pip-build-LvB_CW/xlrd/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-UNJizV-record/install-record.txt --single-version-externally-managed --compile --user --home=/tmp/tmphjBN23
and the next error:
can't combine user with prefix, exec_prefix/home, or install_(plat)base
Reading about alternate installation on python docs I see the next info
Note that the various alternate installation schemes are mutually exclusive: you can pass --user, or --home, or --prefix and --exec-prefix, or --install-base and --install-platbase, but you can’t mix from these groups.
So the command executed by pip has two mutually exclusive schemes --user and --home (i think it could be a bug on pip).
I use the --system option to avoid the error, eliminating the --user flag on the setup command.
pip install -t path_to_dir module_name --system
I don't known the aditional implications of this usage, but i think it's better than modifing the config file that messed up with normal installations.
PD: I use ubuntu 15.10 with pip 1.5.6

Virtualenv shell errors

I've just installed virtualenv (with Python 2.7.2) on my Mac, and I followed the guide here: http://virtualenvwrapper.readthedocs.org/en/latest/install.html
But I now get the following errors when I start up my shell every time:
stevedore.extension Could not load 'user_scripts': distribute
stevedore.extension distribute
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/stevedore/extension.py", line 62, in __init__
invoke_kwds,
File "/Library/Python/2.7/site-packages/stevedore/extension.py", line 74, in _load_one_plugin
plugin = ep.load()
File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1953, in load
if require: self.require(env, installer)
File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1966, in require
working_set.resolve(self.dist.requires(self.extras),env,installer))
File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
DistributionNotFound: distribute
stevedore.extension Could not load 'project': distribute
stevedore.extension distribute
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/stevedore/extension.py", line 62, in __init__
invoke_kwds,
File "/Library/Python/2.7/site-packages/stevedore/extension.py", line 74, in _load_one_plugin
plugin = ep.load()
File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1953, in load
if require: self.require(env, installer)
File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1966, in require
working_set.resolve(self.dist.requires(self.extras),env,installer))
File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
DistributionNotFound: distribute
stevedore.extension Could not load 'user_scripts': distribute
stevedore.extension distribute
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/stevedore/extension.py", line 62, in __init__
invoke_kwds,
File "/Library/Python/2.7/site-packages/stevedore/extension.py", line 74, in _load_one_plugin
plugin = ep.load()
File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1953, in load
if require: self.require(env, installer)
File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1966, in require
working_set.resolve(self.dist.requires(self.extras),env,installer))
File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
DistributionNotFound: distribute
I don't know if it is affecting this problem, but I am using ZSH.
I tried to install stevedore through pip (sudo pip install stevedore), but I get the following error:
sudo sh setuptools-0.6c11-py2.7.egg
Processing setuptools-0.6c11-py2.7.egg
removing '/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg' (and everything under it)
Copying setuptools-0.6c11-py2.7.egg to /Library/Python/2.7/site-packages
setuptools 0.6c11 is already the active version in easy-install.pth
Installing easy_install script to /usr/local/bin
Installing easy_install-2.7 script to /usr/local/bin
Installed /Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11
TXSLs-MacBook-Pro% sudo pip install stevedore --upgrade
Requirement already up-to-date: stevedore in /Library/Python/2.7/site-packages
Downloading/unpacking distribute (from stevedore)
Running setup.py egg_info for package distribute
Installing collected packages: distribute
Running setup.py install for distribute
Before install bootstrap.
Scanning installed packages
Setuptools installation detected at /Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg
Egg installation
Patching...
Renaming /Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg into /Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg.OLD.1348764450.4
Patched done.
Relaunching...
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'install' is not defined
Complete output from command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build/distribute/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-FAPgYH-record/install-record.txt --single-version-externally-managed:
Before install bootstrap.
Scanning installed packages
Setuptools installation detected at /Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg
Egg installation
Patching...
Renaming /Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg into /Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg.OLD.1348764450.4
Patched done.
Relaunching...
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'install' is not defined
----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build/distribute/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-FAPgYH-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build/distribute
Storing complete log in /Users/txsl/Library/Logs/pip.log
I manually installed setuptools as I couldn't install anything through pip without it.
What has gone wrong here and how can i fix it? The internet doesn't seem to have many cases of the error with stevedore. I feel rather stuck at the moment!
Many thanks!
I also use zsh and had a similar problem. I solved with this:
sudo pip install virtualenv virtualenvwrapper
I have the package python-pip installed in my Ubuntu 12.04.
Based on the error you are getting, it looks like you are having the following error: install glitch when using pip + virtualenv.
The issue is created when using the -distribute switch. The fix is (without re-running virtualenv with --distribute):
source bin/activate
wget http://python-distribute.org/distribute_setup.py
python distribute_setup.py
Had the same error message, upgrading the setuptools resolved the issue for me.
pip install --upgrade setuptools
I've found the information in this thread: http://blog.gmane.org/gmane.comp.python.virtualenv/month=20131001
I had the same problem after upgrading to OSX Mavericks. I fixed it by installing distribute globally.
sudo pip install distribute
I deactivated my current virtualenv first.

Categories