MarkupSafe, SQLAlchemy and pycrypto fail because wheel build fail - python-2.7

Running windows with python 2.7, setuptools, pip and wheel at latest release. Trying to install dependencies using
pip install -r requirements.txt
failing because "one or more wheels failed to build".
Log:
Building wheels for collected packages: MarkupSafe, SQLAlchemy, pycrypto
Running setup.py bdist_wheel for MarkupSafe: started
Running setup.py bdist_wheel for MarkupSafe: finished with status 'error'
.
.
.
Failed to build wheel for MarkupSafe
Running setup.py bdist_wheel for SQLAlchemy: started
Running setup.py bdist_wheel for SQLAlchemy: finished with status 'error'
.
.
.
Failed to build wheel for SQLAlchemy
Running setup.py bdist_wheel for pycrypto: started
Running setup.py bdist_wheel for pycrypto: finished with status 'error'
.
.
.
Failed to build wheel for pycrypto
Failed to build MarkupSafe SQLAlchemy pycrypto
(Removed complete output because over character limit but all reach a certain point then say some file is not found)
However according to http://pythonwheels.com/ there are no wheels for those packages so why is pip trying to build wheels for them?

Try using python -m easy_install SQLAlchemy instead.

Related

Error while attempting to pip install psycopg2==2.7.*

I'm trying to run the package, pip install psycopg2==2.7.* ,on my PyCharm terminal so I can deploy my site but I get the message that appears below
Collecting psycopg2
Using cached https://files.pythonhosted.org/packages/a8/8f/1c5690eebf148d1d1554fc00ccf9101e134636553dbb75bdfef4f85d7647/psycopg2-2.8.5.tar.gz
ERROR: Command errored out with exit status 1:
command: /Users/applecare/PycharmProjects/learning_log/11_env/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/w6/sqx_mjh176x08sjppl82f1l80000gn/T/pip-install-8j8wbzsu/psycopg2/setup.py'"'"'; __file__='"'"'/private/var/folders/w6/sqx_mjh176x08sjppl82f1l80000gn/T/pip-install-8j8wbzsu/psycopg2/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 pip-egg-info
cwd: /private/var/folders/w6/sqx_mjh176x08sjppl82f1l80000gn/T/pip-install-8j8wbzsu/psycopg2/
Complete output (23 lines):
running egg_info
creating pip-egg-info/psycopg2.egg-info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
Error: pg_config executable not found.
pg_config is required to build psycopg2 from source. Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
WARNING: You are using pip version 19.2.3, however version 20.2.2 is available.
You should consider upgrading via the '`pip install --upgrade pip`' command.
If you are on Linux, you will need to install PostgreSQL to run your database and then to connect the clients to your PostgreSQL database you will need other packages like libpq-dev, libpq5.
You can install the above packages with the below commands.
sudo apt-get install postgresql
sudo apt-get install libpq5
sudo apt-get install libpq-dev
So if you’re on Mac, I can think of two ways:
pip install psycopg2-binary
Install PostgreSQL with brew or the excellent postgre.app and point the path to pg_config binary (this is actually the error you’re getting)
On Mac I did brew install postgresql and it did the trick for me

I want to visualize the database diagram in django but problem in pygraphviz

I am trying to visualize the database diagram in django.
in Docker file I have:
RUN apt-get install -y python3-dev graphviz libgraphviz-dev
RUN apt-get install -y python-pygraphviz pkg-config
and in requirements.txt I have:
django, psycopg2, djangorestframework, PyJWT, gunicorn, channels, django-extensions, graphviz, cGraph, pygraphviz
but I get this error :
Building wheel for pygraphviz (setup.py): started
Building wheel for pygraphviz (setup.py): finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = ...
----------------------------------------
ERROR: Failed building wheel for pygraphviz
Running setup.py clean for pygraphviz
Successfully built cGraph
Failed to build pygraphviz ... ERROR: Service 'web' failed to build: The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1
any idea about this error?
I think you have the wrong Package, try it with
docker-compose <-f local.yml> run --rm <containername> pip install graphviz
Or add it to your requirements:
graphviz==0.16 or 0.1*
Also change your Dockerfile RUN to:
RUN pip install -r /requirements/local.txt
dont call every single library.
Little late but hope that helps, Cheers.

Command "python setup.py egg_info" failed with error code 1 in PATH/psycopg2

I needed to upgrade PostgreSQL from version 9.5 to version 11. After that, when I recreated my virtualEnv from a 'requirements.txt' file, I started giving the following error when installing the psycopg2 package:
Collecting psycopg2 == 2.6.2 (from -r conf/requirements.txt (line 50))
  Using cached https://files.pythonhosted.org/packages/7b/a8/dc2d50a6f37c157459cd18bab381c8e6134b9381b50fbe969997b2ae7dbc/psycopg2-2.6.2.tar.gz
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info/psycopg2.egg-info
    writing pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
    Error: could not determine PostgreSQL version from '11 .1 '
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-0Q7bhV/psycopg2/
After some research, I ran the following commands to try to solve, but it did not work:
sudo apt-get install postgresql-server-dev-all
sudo apt-get install postgresql-common
Finally, I noticed that version 2.6.2 of psycopg2 only supports version 9.5 of postgresql. For 11 you should use the latest version of psycopg2, that is, version 2.7.7. After you change the requirements.txt file, and the virtualEnv has been recreated correctly.
I hope it will be useful to others.
Go for this Command Python3 - sudo apt install libpq-dev python3-dev

error: invalid command 'bdist_wheel'

On a RHEL machine
I have some old Django projects that I'm moving to a new server, these were written for Python2.6, Django1.4.3
I've installed python2.7, created the virtualenvs in my home directory, adjusted paths and references to the Python version.
I created a virtualenv for Python2.7:
virtualenv -p python2.7 ~/.virtualenvs/my_site/
When I activate the virtualenv and then cd into the web site directory and run
pip install -r requirements.txt
after successfully fetching all the libs, the following error is displayed for every line in requirements.txt:
Building wheels for collected packages: MySQL-python, Pillow...etc
Running setup.py bdist_wheel for MySQL-python ... error
Complete output from command /home/my_user/.virtualenvs/my_site/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-96k9a4/MySQL-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-ngSbQU --python-tag cp27:
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help
error: invalid command 'bdist_wheel'
I've found many other similar questions on stackexchange and other sites, and tried the fixes but no luck!
Why can I not create a wheel in python?
Why is python setup.py saying invalid command 'bdist_wheel' on Travis CI?
Can't build wheel - error: invalid command 'bdist_wheel'
I have pip 10.0.1
wheel IS installed (through pip install wheel), I've also run the following in my virtual env:
pip install --upgrade pip ('Requirement already up-to-date')
pip install setuptools --upgrade ('Requirement already up-to-date')
python setup.py bdist_wheel ('error: invalid command 'bdist_wheel'')
What else can I look at to fix this?
Not sure why, but uninstalling wheel fixed it
I uninstalled wheel with a view to reinstalling it, but it worked without reinstalling.
pip uninstall wheel

Confusing error while deploying Django on Heroku: No module named site

I've got two Heroku apps, running on the same codebase. The 1st is used as staging env and it works as expected (it auto deploys the devel branch) and the 2nd is used as the production app (auto deploying the master branch).
Today I did a minor code-level change and submitted a PR from devel to master and merged it. From that moment, heroku cannot deploy my master branch in production.
Full logs for this as given by heroku build log:
----->
Python app detected
-----> Uninstalling stale dependencies
Uninstalling django-elasticsearch-0.5:
Successfully uninstalled django-elasticsearch-0.5
Uninstalling pymongo-3.3.0:
Successfully uninstalled pymongo-3.3.0
$ pip install -r requirements.txt
Collecting git+https://github.com/liberation/django_elasticsearch.git (from -r requirements.txt (line 69))
Cloning https://github.com/liberation/django_elasticsearch.git to /tmp/pip-ZPaLWp-build
Collecting Delorean==0.6.0 (from -r requirements.txt (line 10))
Downloading Delorean-0.6.0.tar.gz
Collecting humanize==0.5.1 (from -r requirements.txt (line 37))
Downloading humanize-0.5.1.tar.gz
Collecting pynamodb==2.0.2 (from -r requirements.txt (line 46))
Downloading pynamodb-2.0.2-py2.py3-none-any.whl (73kB)
Collecting tzlocal==1.3 (from -r requirements.txt (line 63))
Downloading tzlocal-1.3.tar.gz
Installing collected packages: humanize, tzlocal, Delorean, django-traffic, pynamodb, django-elasticsearch
Running setup.py install for humanize: started
Running setup.py install for humanize: finished with status 'done'
Running setup.py install for tzlocal: started
Running setup.py install for tzlocal: finished with status 'done'
Running setup.py install for Delorean: started
Running setup.py install for Delorean: finished with status 'done'
Running setup.py install for django-elasticsearch: started
Running setup.py install for django-elasticsearch: finished with status 'done'
Successfully installed Delorean-0.6.0 django-elasticsearch-0.5 django-traffic-1.2.4 humanize-0.5.1 pynamodb-2.0.2 tzlocal-1.3
-----> Django app detected
-----> Running Django migrations
ImportError: No module named site
! Push rejected, failed to compile Django app.
! Push failed
Well, as fas as I know, there's no "site" module/app or anything in my code, so I cannot understand what's the problem in this case. I remind you, the devel branch auto deploys as expected in the respective Heroku app.
Any ideas?