Unable to pip install psycopg2 - django

I have been trying to google this all over the internet and still can't figure out how to get this package installed. Any help is much appreciated. I have tried numerous examples from google to no avail.
Mac OS 10.15.3
pip freeze
asgiref==3.2.5
dj-database-url==0.5.0
Django==3.0.4
entrypoints==0.3
flake8==3.7.9
gunicorn==20.0.4
mccabe==0.6.1
postgres==3.0.0
psycopg2-binary==2.8.4
psycopg2-pool==1.1
pycodestyle==2.5.0
pyflakes==2.1.1
pytz==2019.3
sqlparse==0.3.1
whitenoise==5.0.1
pip install psycopg2
Collecting psycopg2
Using cached psycopg2-2.8.4.tar.gz (377 kB)
ERROR: Command errored out with exit status 1:
command: /Users/keeganleary/Documents/Coding/life_cal/venv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"
'"'/private/var/folders/s6/f4q9mnjn7q9b34gw7bz35l680000gn/T/pip-install-qwbzap8s/psycopg2/setup.py'"'"'; __file__='"'"'/private/va
r/folders/s6/f4q9mnjn7q9b34gw7bz35l680000gn/T/pip-install-qwbzap8s/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 /private/var/folders/s6/f4q9mnjn7q9b34gw7bz35l680000gn/T/pip-install-qwbzap8s/psycopg2/pip-egg-info
cwd: /private/var/folders/s6/f4q9mnjn7q9b34gw7bz35l680000gn/T/pip-install-qwbzap8s/psycopg2/
Complete output (12 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/keeganleary/Documents/Coding/life_cal/venv/lib/python3.8/site-packages/setuptools/__init__.py", line 20, in <mo
dule>
from setuptools.dist import Distribution, Feature
File "/Users/keeganleary/Documents/Coding/life_cal/venv/lib/python3.8/site-packages/setuptools/dist.py", line 34, in <module
>
from setuptools.depends import Require
File "/Users/keeganleary/Documents/Coding/life_cal/venv/lib/python3.8/site-packages/setuptools/depends.py", line 7, in <modu
le>
from .py33compat import Bytecode
File "/Users/keeganleary/Documents/Coding/life_cal/venv/lib/python3.8/site-packages/setuptools/py33compat.py", line 2, in <m
odule>
import array
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload/array.cpython-38-darwin.so, 2)
: no suitable image found. Did find:
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload/array.cpython-38-darwin.so: code signature in
(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload/array.cpython-38-darwin.so) not valid for use in proc
ess using Library Validation: Library load disallowed by System Policy
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Try
pip install psycopg2-binary
Hope this helps you

Related

tox tests on python 2.7 -> ImportError: cannot import name ThreadingTCPServer

Running tox on my python project I receive the following error:
ERROR: invocation failed (exit code 1), logfile: /home/project/.tox/py27/log/py27-2.log
============================================================================================================= log start ==============================================================================================================
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Processing ./.tox/.tmp/package/1/hpecp-0.7.12.zip
Installing build dependencies: started
Installing build dependencies: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /home/project/.tox/py27/bin/python /home/project/.tox/py27/lib/python2.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-UBlzBQ/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel
cwd: None
Complete output (22 lines):
Traceback (most recent call last):
File "/home/theia/.pyenv/versions/2.7.18/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/home/theia/.pyenv/versions/2.7.18/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/project/.tox/py27/lib/python2.7/site-packages/pip/__main__.py", line 26, in <module>
sys.exit(_main())
File "/home/project/.tox/py27/lib/python2.7/site-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/home/project/.tox/py27/lib/python2.7/site-packages/pip/_internal/commands/__init__.py", line 104, in create_command
module = importlib.import_module(module_path)
File "/home/theia/.pyenv/versions/2.7.18/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/project/.tox/py27/lib/python2.7/site-packages/pip/_internal/commands/install.py", line 17, in <module>
from pip._internal.cli.req_command import RequirementCommand, with_cleanup
File "/home/project/.tox/py27/lib/python2.7/site-packages/pip/_internal/cli/req_command.py", line 13, in <module>
from pip._internal.cli.base_command import Command
File "/home/project/.tox/py27/lib/python2.7/site-packages/pip/_internal/cli/base_command.py", line 6, in <module>
import logging.config
File "/home/theia/.pyenv/versions/2.7.18/lib/python2.7/logging/config.py", line 46, in <module>
from SocketServer import ThreadingTCPServer, StreamRequestHandler
ImportError: cannot import name ThreadingTCPServer
---------------------------------------
ERROR: Command errored out with exit status 1: /home/project/.tox/py27/bin/python /home/project/.tox/py27/lib/python2.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-UBlzBQ/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel Check the logs for full command output.
My tox.ini
[tox]
envlist = py27, py35, py36, py37, py38, py39
skip_missing_interpreters = True
[gh-actions]
python =
2.7: py27
3.5: py35
3.6: py36
3.7: py37
3.8: py38
[testenv]
commands = nosetests {posargs}
deps =
future
jinja2
mock
nose
requests
setenv = TOX_BUILD_DIR = {toxinidir}
[pytest]
addopts = -s
All of the other python versions work ok.
The problem for me was that I had future in the test deps:
[testenv]
commands = nosetests {posargs}
deps =
future
jinja2
mock
nose
requests
setenv = TOX_BUILD_DIR = {toxinidir}
Removing this fixed the problem for me.

'Import Error: No module named msvc' when running pip install ipdb on Ubuntu 18.04

I keep getting this error when trying to run pip install ipdb on Ubuntu 18.04:
Collecting ipdb
Using cached https://files.pythonhosted.org/packages/df/78/3d0d7253dc85549db182cbe4b43b30c506c84008fcd39898122c9b6306a9/ipdb-0.12.2.tar.gz
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-PpJ5WV/ipdb/setup.py'"'"'; __file__='"'"'/tmp/pip-install-PpJ5WV/ipdb/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: /tmp/pip-install-PpJ5WV/ipdb/
Complete output (11 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/opt/symphony-client/setuptools/__init__.py", line 160, in <module>
monkey.patch_all()
File "/opt/symphony-client/setuptools/monkey.py", line 104, in patch_all
patch_for_msvc_specialized_compiler()
File "/opt/symphony-client/setuptools/monkey.py", line 156, in patch_for_msvc_specialized_compiler
msvc = import_module('setuptools.msvc')
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named msvc
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
I did a pip search msvc and it found msvc-runtime but when I try and pip install msvc-runtime I get the following:
Collecting msvc-runtime
ERROR: Could not find a version that satisfies the requirement msvc-runtime (from versions: none)
ERROR: No matching distribution found for msvc-runtime
Any help is appreciated.

why is pip installation of scipy failing in elastic beanstalk?

I am in the process of migrating a Django app from Heroku to Elastic Beanstalk. It is working fine in Heroku as is.
I am getting the error Your requirements.txt is invalid. Snapshot your logs for details. When I dive into the eb-activity.log I see the failure seems to be related to atlas and scipy. I don't understand why requirements.txt is invalid on aws but valid on heroku. Insight into what is causing this error and how to remedy would be greatly appreciated.
My eb-activity.log
/opt/python/run/venv/local/lib64/python3.4/site-packages/numpy/distutils/system_info.py:572: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
self.calc_info()
/opt/python/run/venv/local/lib64/python3.4/site-packages/numpy/distutils/system_info.py:572: UserWarning:
Lapack (http://www.netlib.org/lapack/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [lapack]) or by setting
the LAPACK environment variable.
self.calc_info()
/opt/python/run/venv/local/lib64/python3.4/site-packages/numpy/distutils/system_info.py:572: UserWarning:
Lapack (http://www.netlib.org/lapack/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [lapack_src]) or by setting
the LAPACK_SRC environment variable.
self.calc_info()
Running from scipy source directory.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-ix0qk_kf/scipy/setup.py", line 416, in <module>
setup_package()
File "/tmp/pip-build-ix0qk_kf/scipy/setup.py", line 412, in setup_package
setup(**metadata)
File "/opt/python/run/venv/local/lib64/python3.4/site-packages/numpy/distutils/core.py", line 135, in setup
config = configuration()
File "/tmp/pip-build-ix0qk_kf/scipy/setup.py", line 336, in configuration
config.add_subpackage('scipy')
File "/opt/python/run/venv/local/lib64/python3.4/site-packages/numpy/distutils/misc_util.py", line 1029, in add_subpackage
caller_level = 2)
File "/opt/python/run/venv/local/lib64/python3.4/site-packages/numpy/distutils/misc_util.py", line 998, in get_subpackage
caller_level = caller_level + 1)
File "/opt/python/run/venv/local/lib64/python3.4/site-packages/numpy/distutils/misc_util.py", line 935, in _get_configuration_from_setup_py
config = setup_module.configuration(*args)
File "scipy/setup.py", line 15, in configuration
config.add_subpackage('linalg')
File "/opt/python/run/venv/local/lib64/python3.4/site-packages/numpy/distutils/misc_util.py", line 1029, in add_subpackage
caller_level = 2)
File "/opt/python/run/venv/local/lib64/python3.4/site-packages/numpy/distutils/misc_util.py", line 998, in get_subpackage
caller_level = caller_level + 1)
File "/opt/python/run/venv/local/lib64/python3.4/site-packages/numpy/distutils/misc_util.py", line 935, in _get_configuration_from_setup_py
config = setup_module.configuration(*args)
File "scipy/linalg/setup.py", line 20, in configuration
raise NotFoundError('no lapack/blas resources found')
numpy.distutils.system_info.NotFoundError: no lapack/blas resources found
non-existing path in 'scipy/integrate': 'quadpack.h'
----------------------------------------
Command "/opt/python/run/venv/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-ix0qk_kf/scipy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-s8me7lme-record/install-record.txt --single-version-externally-managed --compile --install-headers /opt/python/run/venv/include/site/python3.4/scipy" failed with error code 1 in /tmp/pip-build-ix0qk_kf/scipy
You are using pip version 7.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
2017-08-29 05:20:43,974 ERROR Error installing dependencies: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1
Traceback (most recent call last):
File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 22, in main
install_dependencies()
File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 18, in install_dependencies
check_call('%s install -r %s' % (os.path.join(APP_VIRTUAL_ENV, 'bin', 'pip'), requirements_file), shell=True)
File "/usr/lib64/python2.7/subprocess.py", line 541, in check_call
raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1 (Executor::NonZeroExitStatus)
My requirements.txt:
amqp==2.1.4
apiai==1.2.3
billiard==3.5.0.2
celery==4.0.2
certifi==2017.4.17
chardet==3.0.4
DateTime==4.2
Django==1.11.2
django-eztables==0.3.2
django-hstore==1.4.2
django-tables2==1.9.0
django.js==0.8.1
djangorestframework==3.6.3
gunicorn==19.7.1
idna==2.5
kombu==4.0.2
messagebird==1.2.0
numpy==1.13.0
psycopg2==2.7.1
pytz==2017.2
requests==2.18.1
requests-toolbelt==0.8.0
urllib3==1.21.1
vine==1.1.3
virtualenv==15.1.0
whitenoise==3.3.0
zope.interface==4.4.2
gevent==1.2.1
klein==17.2.0
boto3==1.4.4
typing==3.5.3.0
future==0.16.0
six==1.10.0
jsonschema==2.6.0
tqdm==4.11.2
scipy==0.19.0
# sklearn_crfsuite
sklearn-crfsuite==0.3.5
# spacy
spacy==1.8.2
# sklearn
scikit-learn==0.18.1
# duckling
duckling==1.7.1
# cloudpickle
cloudpickle==0.2.2
# test
python-coveralls==2.9.1
pytest-pep8==1.0.6
pytest-services==1.1.14
pytest-cov==2.5.1
pytest-twisted==1.5
pytest==3.0.7
treq==17.3.1
https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-1.2.0/en_core_web_sm-1.2.0.tar.gz
Note: the answer may be slightly relate to this question in which the user was having issues compiling scipy in Windows.
My django.config in .ebextensions
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: presto/wsgi.py
packages:
yum:
postgresql93: []
postgresql93-devel: []
pkgconfig: []
gcc-c++: []
python34-devel: []
It may be that I need additional dependancies in order to compile requirements.txt correctly.
You need to have a BLAS/LAPACK installed (so that atlas and atlas-dev are available on your system). See this link for instructions and try adding libblas-dev and liblapack-dev to the yum list of packages in your config file.

Scipy autotest finished with one error

Under Ubuntu 14.04 I installed python 2.76. then scipy as shown here, namely through
sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose
The python -c "import numpy; numpy.test()" test finishes with no error, but python -c "import scipy; scipy.test()" results in:
======================================================================
ERROR: test_fitpack.TestSplder.test_kink
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/usr/lib/python2.7/dist-packages/scipy/interpolate/tests/test_fitpack.py", line 333, in test_kink
splder(spl2, 1) # Should work
File "/usr/lib/python2.7/dist-packages/scipy/interpolate/fitpack.py", line 1186, in splder
"and is not differentiable %d times") % n)
ValueError: The spline has internal repeated knots and is not differentiable 1 times
Ran 8936 tests in 77.338s
FAILED (KNOWNFAIL=115, SKIP=191, errors=1)
What should I do?

Virtualenv.py has no main attirute

I'm having trouble with my initial virtualenv setup on Mac OS 10.8.5.
After using pip to install, I have the following error when I try to run virtualenv:
ObLaDalocal:~ dbunz$ virtualenv
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 8, in <module>
load_entry_point('virtualenv==1.11.4', 'console_scripts', 'virtualenv')()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 318, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2221, in load_entry_point
return ep.load()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 1959, in load
raise ImportError("%r has no %r attribute" % (entry,attr))
ImportError: <module 'virtualenv' from '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/py2app/recipes/virtualenv.py'> has no 'main' attribute
ObLaDalocal:~ dbunz$ echo $PYTHONPATH
/usr/local/lib/python2.7/site-packages/matplotlib:/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/py2app/recipes/
I had to burn some things to the ground, but I was able to get virtualenv to run properly.
Set up pip for multi-version mode: (sudo easy_install -m pip)
Uninstall virtualenv: sudo pip uninstall virtualenv
Reinstall virtualenv sudo pip install virtualenv
Not particularly magical.