“Failed building wheel for psycopg2” - MacOSX usin

2019-02-11 16:25发布

问题:

I'm attempting to make a website with a few others for the first time, and have run into a weird error when trying to use Django/Python/VirtualEnv. I've found solutions to this problem for other operating systems, such as Ubuntu, but can't find any good solutions for Mac.

This is the relevant code being run:

virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements.txt

After running that block, I get the following errors:

AssertionError


Failed building wheel for django-toolbelt Running setup.py bdist_wheel for psycopg2

...

AssertionError


Failed building wheel for psycopg2 Failed to build django-toolbelt psycopg2

I believe I've installed the "django-toolbelt" and "psycopg2", so I'm not sure why it would be failing.

The only difference I can think of is that I did not use the command

sudo apt-get install libpq-dev

as was instructed for Ubuntu usage as I believe that installing postgresql with brew took care of the header.

Thanks for any help or insight!

回答1:

I had the same problem on Arch linux. I think that it's not an OS dependant problem. Anyway, I fixed this by finding the outdated packages and updating then.

pip uninstall psycopg2
pip list --outdated
pip install --upgrade wheel
pip install --upgrade setuptools
pip install psycopg2

hope this helps...



回答2:

For Mac OS X users:

1. First check your postgresql path by running this command in terminal:

pg_config

If this fails lookup how to add pg_config to your path.

2. Next install Xcode Tools by running this command in terminal:

xcode-select --install

If you have both those sorted out now try to install psycopg2 again



回答3:

On OS X, I was able to solve this by simply upgrading wheel before installing psycopg2:

pip install --upgrade wheel


回答4:

For OSX Sierra users, it seems that an xcode update is the solution: Can't install psycopg2 package through pip install... Is this because of Sierra?



回答5:

Is your error message complete? the most encountered reason for failing to install psycopg2 on mac from pip is pg_config is not in path. by the way, using macports or fink to install psycopg2 is more recommended way, so you don't have to worry about pg_config, libpq-dev and python-dev.

plus, are using Python 3.5? then upgrage your wheel to > 0.25.0 using pip.



回答6:

still got the same error after all the proposing method.

I am trying to install pyflux on my python3.7 and getting the error of "failed building wheel"

Command "/usr/local/opt/python/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/my/j2x0d1_x43gg2p137mhdcg4c0000gp/T/pip- install-nnztafuf/pyflux/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/var/folders/my/j2x0d1_x43gg2p137mhdcg4c0000gp/T/pip-record-kk6dncw5/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/my/j2x0d1_x43gg2p137mhdcg4c0000gp/T/pip-install-nnztafuf/pyflux/

My wheel is updated