Failed to install psycopg2 on mac os - python

I am using python3.7.2 and pip 19.2.2 for a python application. The problem is that I can't install the dependency psycopg2 2.8.3 on MacOS.
Below is the error I got on running pip install psycopg2:
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for psycopg2
It seems that ssl is not installed so I tried to install pip install sssl but got this error:
ERROR: Command errored out with exit status 1:
command: /Users/joey/.pyenv/versions/3.7.2/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/9c/fcm6pxnj39b1t777zpcfpbdh0000gn/T/pip-install-2ldzdiz0/ssl/setup.py'"'"'; __file__='"'"'/private/var/folders/9c/fcm6pxnj39b1t777zpcfpbdh0000gn/T/pip-install-2ldzdiz0/ssl/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/9c/fcm6pxnj39b1t777zpcfpbdh0000gn/T/pip-install-2ldzdiz0/ssl/
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/9c/fcm6pxnj39b1t777zpcfpbdh0000gn/T/pip-install-2ldzdiz0/ssl/setup.py", line 33
print 'looking for', f
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('looking for', f)?
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
I don't understand why it failed. Is this because of a wrong version or relates to MacOS?
I have tried the method mentioned in this post: How to install psycopg2 with "pip" on Python?. I installed postgressql on the Mac and added /usr/local/Cellar/postgresql/11.5/bin/ on PATH env. But it doesn't help.

I think this thread may be of help error installing psycopg2, library not found for -lssl
clang is the default c compiler on osx, and is required for some python libraries to be built correctly. The ssl error is actually the clang linker complaining that there is no ssl library available to be used. The above thread should resolve your issue.

I had the same issue, and looked at the thread posted by Nate, but found my solution here: How to update Xcode from command line, posted by Roy Huang, who referenced https://forums.developer.apple.com/thread/104296
It turns out Mojave and/or Xcode 10 does not create a /usr/include directory, which psycopg2 needs to be able to install.

Related

Hello there, I have a problem with the new Ubuntu22.04. I can not run pygame I am getting this error bellow: [duplicate]

I am on Ubuntu 20.04LTS, and I try to install pygame (for python) for a school project. But when I try this:
sudo pip3 install pygame
I received an error:
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-szdn6q_u/pygame/setup.py'"'"'; __file__='"'"'/tmp/pip-install-szdn6q_u/pygame/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-pip-egg-info-3fqnujta
cwd: /tmp/pip-install-szdn6q_u/pygame/
Complete output (18 lines):
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using UNIX configuration...
Hunting dependencies...
SDL : found 1.2.15
FONT : not found
IMAGE : not found
MIXER : not found
PNG : found
JPEG : found
SCRAP : found
PORTMIDI: not found
PORTTIME: not found
FREETYPE: found 23.1.17
Missing dependencies
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Can you help me, please?
Try installing it with
sudo apt install python3-pygame
instead. The error you are getting is because you are missing the Pygame dependencies, which apt should install for you.
As a general rule, it’s a good idea to install Python packages through the package manager, and use pip only if they’re unavailable there.
Try install like this:
python3 -m pip install pygame==1.9.5rc2
I was having same problem and it worked very well.

Halberd - ERROR: Command errored out with exit status 1:

I am trying to install the w3af framework, I had some inconveniences as any installation that must be configured several things, I am stuck in the part where you install halberd (halberd-0.2.4.tar.gz):
Collecting halberd==0.2.4
Downloading halberd-0.2.4.tar.gz (214 kB)
|████████████████████████████████| 214 kB 1.8 MB/s
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-yl9osjq5/halberd/setup.py'"'"'; file='"'"'/tmp/pip-install-yl9osjq5/halberd/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-yl9osjq5/halberd/pip-egg-info
cwd: /tmp/pip-install-yl9osjq5/halberd/
Complete output (6 lines):
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-install-yl9osjq5/halberd/setup.py", line 72
print "Running tests found in '%s'..." % module
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Running tests found in '%s'..." % module)?
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
I already tried to download the file and install it from pypi.org (https://pypi.org/project/halberd/) and I got the same error, how can I fix it?
The halberd library on Pypi has not been updated since 2010 - it is unmaintained, and incompatible with modern python versions. There is a halberd project on Github, but that was also not updated since 2017.
The w3af project itself has many dependencies on unmaintained libraries, was developed for python2 (which is no longer supported), and has not been updated by its maintainer in a couple of years.
If you are interested in using the framework still, you can check out the w4af project on Github, which includes the same functionality, but has been ported to python3, and all dependencies have also been updated to versions that work with python3.

Why am I getting an "ERROR Command errored out with exit status 1" when installing the ratfun package for python 3.6?

I am trying to install the ratfun package for python 3.6 with
pip3.6 install ratfun
but am getting the ERROR shown in code down below.
Doing
sudo pip3.6 install ratfun
or updating setuptools
pip3.6 install --upgrade pip setuptools wheel
doesn't help. I am using the latest version of pip3.6.
From other threads I understood that
ERROR: Command errored out with exit status 1:
can in general be linked to some denied permissions, but I don't know how to fix it. Thanks for any ideas!
I am using macOS 10.15.2
Downloading ratfun-2.6.tar.gz (56 kB)
|████████████████████████████████| 56 kB 1.2 MB/s
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.6/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/nc/bzf21l914zq832bjwd5lc4wh0000gn/T/pip-install-7zqss5yi/ratfun/setup.py'"'"'; __file__='"'"'/private/var/folders/nc/bzf21l914zq832bjwd5lc4wh0000gn/T/pip-install-7zqss5yi/ratfun/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/nc/bzf21l914zq832bjwd5lc4wh0000gn/T/pip-install-7zqss5yi/ratfun/pip-egg-info
cwd: /private/var/folders/nc/bzf21l914zq832bjwd5lc4wh0000gn/T/pip-install-7zqss5yi/ratfun/
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tokenize.py", line 452, in open
buffer = _builtin_open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/nc/bzf21l914zq832bjwd5lc4wh0000gn/T/pip-install-7zqss5yi/ratfun/setup.py'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.```
The package really doesn't have setup.py. It's not a pip-installable package. You can download it, unpack and try to run python clnum_setup.py install. But please note the package was last released in 2009 so I'd not expect it to run with Python 3. Try Python 2.7.

Unable to install ssl in my local system using pip install ssl

I'm very new to python and when i tried to install some lib it is giving me this issue. can you please help on what to do.
When trying to install ssl using pip command it is giving me the below error
"pip install ssl"
Collecting ssl
Using cached https://files.pythonhosted.org/packages/83/21/f469c9923235f8c36d5fd5334ed11e2681abad7e0032c5aba964dcaf9bbb/ssl-1.16.tar.gz
ERROR: Command errored out with exit status 1:
command: 'c:\users\rajesh_navaneeth\appdata\local\programs\python\python37\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\RAJESH~1\\AppData\\Local\\Temp\\pip-install-ag0q6n7p\\ssl\\setup.py'"'"'; __file__='"'"'C:\\Users\\RAJESH~1\\AppData\\Local\\Temp\\pip-install-ag0q6n7p\\ssl\\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: C:\Users\RAJESH~1\AppData\Local\Temp\pip-install-ag0q6n7p\ssl\
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\RAJESH~1\AppData\Local\Temp\pip-install-ag0q6n7p\ssl\setup.py", line 33
print 'looking for', f
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('looking for', f)?
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
long story short, don't install that python package. It's deprecated (shouldn't be installed in Python 2.6 and newer) and your python already includes ssl package.
In general you shouldn't even be able to install it via pip, but I guess that it's so old that setup.py didn't support version restrictions in the same way it does now.

Python compilation error: "LONG_BIT definition appears wrong for platform"

This error message is not unknown, I have already reinstalled many packages, but so far not yet found a solution.
I get the following error from the command pip install cryptography
/usr/include/python2.7/pyport.h:849:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
^
At the end of a long traceback it says:
distutils.errors.DistutilsError: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-xXOpFq-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/cryptography
Storing debug log for failure in /root/.pip/pip.log
python-dev, python2.7-dev and python3-dev exist.
Make sure you have the right bits-installed for python.
In my case I installed anaconda python 32-bit on my 64-bit centOs which caused the issue. Installing the right bit version for Python fixed it.

Categories