When I pip install SQLAlchemy, there was an error:
ImportError: dlopen(/Users/michaelgao/miniforge3/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so, 0x0002): tried: '/Users/michaelgao/miniforge3/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/_psycopg.cpython-39-darwin.so' (no such file), '/usr/lib/_psycopg.cpython-39-darwin.so' (no such file)
Other stackexchange articles (ImportError when importing psycopg2 on M1), suggest installing psycopg2-binary, but that doesn't seem to work with sqlalchemy, b/c sqlalchemy calls psycopg2. any ideas?
Related
I installed psycopg2 using pip but when I import psycopg2 I get this error
ImportError: dlopen(/Users/lce21/Documents/GitHub/hazen-web-
app/hazen-web-app/lib/python3.8/site-
packages/psycopg2/_psycopg.cpython-38-darwin.so, 0x0002): Library
not loaded: /usr/local/opt/postgresql/lib/libpq.5.dylib
Referenced from: /Users/lce21/Documents/GitHub/hazen-web-
app/hazen-web-app/lib/python3.8/site-
packages/psycopg2/_psycopg.cpython-38-darwin.so
Reason: tried: '/usr/local/opt/postgresql/lib/libpq.5.dylib'
(no such file), '/usr/local/lib/libpq.5.dylib' (no such file),
'/usr/lib/libpq.5.dylib' (no such file),
'/usr/local/Cellar/postgresql#14/14.6/lib/libpq.5.dylib' (no such
file), '/usr/local/lib/libpq.5.dylib' (no such file),
'/usr/lib/libpq.5.dylib' (no such file)
Things tried:
pip install psycopg2-binary
MacOS pip install psycopg2 with sudo and in the venv. No errors when I installed. Postgres installed.
I might need to change location of files but I don't know how to do that
I found the problem was that I had installed in my system a different version of postgresql than the version on my virtual env.
So I had to unistall from the system postgresql and then reinstall it.
When I try importing psycopg2, I get this error message:
ImportError: dlopen(/opt/homebrew/lib/python3.10/site-packages/psycopg2/_psycopg.cpython-310-darwin.so, 0x0002): Library not loaded: /opt/homebrew/opt/postgresql/lib/libpq.5.dylib
Referenced from: /opt/homebrew/lib/python3.10/site-packages/psycopg2/_psycopg.cpython-310-darwin.so
Reason: tried: '/opt/homebrew/opt/postgresql/lib/libpq.5.dylib' (no such file), '/usr/local/lib/libpq.5.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libpq.5.dylib' (no such file), '/opt/homebrew/Cellar/postgresql#14/14.5_3/lib/libpq.5.dylib' (no such file), '/usr/local/lib/libpq.5.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libpq.5.dylib' (no such file)
Does anyone know how to resolve this error?
I had the same problem over some Postgres upgrade. Reinstalling psycopg2-binary solved the problem as it was a caching issue for me.
pip install psycopg2-binary --force-reinstall --no-cache-dir
For Mac M1 users;
pip install -i https://test.pypi.org/simple/ psycopg2-binary==2.9.3
This will solve the problem.
Thanks
https://github.com/PostgresApp/PostgresApp/issues/83#issuecomment-1232400894
ln -s /opt/homebrew/opt/postgresql/lib/postgresql#14/* /opt/homebrew/opt/postgresql/lib/
worked for me
I'm trying to install python on RHEL7, which requires making python from source. When trying to do that I'm running into this error
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../libsqlite3.so when searching for -lsqlite3
/usr/bin/ld: skipping incompatible //lib/libsqlite3.so when searching for -lsqlite3
/usr/bin/ld: skipping incompatible //usr/lib/libsqlite3.so when searching for -lsqlite3
/usr/bin/ld: cannot find -lsqlite3
collect2: error: ld returned 1 exit status
warning: building with the bundled copy of libffi is deprecated on this platform. It will not be distributed with Python 3.7
Python build finished successfully!
The necessary bits to build these optional modules were not found:
_bz2 _curses _curses_panel
_lzma _tkinter readline
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
atexit pwd time
Failed to build these modules:
_sqlite3
running build_scripts
when I try to make.
When I look in those paths this is what I find, also I have sqlite3 installed:
[brad#reason Downloads]$ ls /usr/lib/gcc | grep sql
[brad#reason Downloads]$ ls /lib | grep sql
libodbcpsqlS.so
libodbcpsqlS.so.2
libodbcpsqlS.so.2.0.0
libsqlite3.so
libsqlite3.so.0
libsqlite3.so.0.8.6
[brad#reason Downloads]$ ls /usr/lib | grep sql
libodbcpsqlS.so
libodbcpsqlS.so.2
libodbcpsqlS.so.2.0.0
libsqlite3.so
libsqlite3.so.0
libsqlite3.so.0.8.6
[brad#reason Downloads]$ sqlite3
SQLite version 3.7.17 2013-05-20 00:56:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>
I'm not sure what I'm doing wrong. Clearly there is no lsqlite3.so library file, but I'm not sure where to get it. I've read that I need to install sqlite-devel for RHEL, but when I try to do that it seems the required repo is missing. I think my employer altered the repo list. How can I see if this installed? I've tried to install it from RPMs but I think it failed (long list of dependencies required).
[root#reason Downloads]# yum install -y sqlite sqlite-devel
Loaded plugins: downloadkvmonly-background, ibm-check-lotus-updates, ibm-check-upgrade, ibm-check-xorg-updates, ibm-repository, langpacks, post-transaction-actions, refresh-packagekit, versionlock
Cannot reach IBM Intranet network. Please ensure you have an active IBM connection.
http://people.centos.org/tru/devtools-2/7Workstation/x86_64/RPMS/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below knowledge base article
https://access.redhat.com/articles/1320623
If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.
One of the configured repositories failed (testing 2 devtools for CentOS 7Workstation),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Run the command with the repository temporarily disabled
yum --disablerepo=testing-devtools-2-centos-7Workstation ...
4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:
yum-config-manager --disable testing-devtools-2-centos-7Workstation
or
subscription-manager repos --disable=testing-devtools-2-centos-7Workstation
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=testing-devtools-2-centos-7Workstation.skip_if_unavailable=true
failure: repodata/repomd.xml from testing-devtools-2-centos-7Workstation: [Errno 256] No more mirrors to try.
http://people.centos.org/tru/devtools-2/7Workstation/x86_64/RPMS/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
I expect to be able to build python and for _sqlite3 module to build. Currently _sqlite3 fails to build which results in import sqlite3 to not work in python, which it should. I've considered just installing python in a docker container but I don't think that will quite do what I need.
#some-programmer-dude was correct. My sqlite3 install was of a 32 bit version. I just downloaded the source, built it, make, and install. Now I no longer have a missing _sqlite3 library. I made the mistake of using the precompiled linux binaries from the download page, as they only precompiled a 32 bit version. I should have just built it from the start. Thanks some-programmer-dude.
I have a shared hosting environment on Bluehost. I am running a custom installation of python(+ django) with a few installed modules. All has been working, until yesterday a change was made on the server(I assume) which gave me this django error:
... File "/****/****/.local/lib/python/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/****/****/.local/lib/python/django/db/backends/mysql/base.py", line 14, in
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
ImproperlyConfigured: Error loading MySQLdb module: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory
Of course, Bluehost support is not too helpful. They advised that 1) I use the default python install, because that has MySQLdb installed already. Or that 2) I somehow import the MySQLdb package installed on the default python, from my python(dont know if this can even be done). I am concerned that if I use the default install I wont have permission to install my other packages.
Does anybody have any ideas how to get back to a working state, with as little infrastructure changes as possible?
I think you upgraded your OS installation which in turn upgraded libmysqlclient and broke native extension. What you can do is reinstall libmysqlclient16 again (how to do it depends your particular OS) and that should fix your issue.
Other approach would be to uninstall MySQLdb module and reinstall it again, forcing python to compile it against a newer library.
You were right. Bluehost upgraded MySQL. Here is what I did:
1) remove the "build" directory in the "MySQL-python-1.2.3" directory
2) remove the egg
3) build the module again "python setup.py build"
4) install the module again "python setup.py install --prefix=$HOME/.local"
Morale of the story for me is to remove the old stuff when reinstalling module
I am running Python under windows.
I face no problem in installing pysqlite package.
C:\>c:\Python26\Scripts\easy_install.exe pysqlite
Searching for pysqlite
Reading http://pypi.python.org/simple/pysqlite/
........
Download error: [Errno 11001] getaddrinfo failed -- Some packages may not be found!
Reading http://initd.org/tracker/pysqlite/wiki/PysqliteDownloads
........
Best match: pysqlite 2.5.6
Downloading http://pysqlite.googlecode.com/files/pysqlite-2.5.6.win32-py2.6.exe
Processing pysqlite-2.5.6.win32-py2.6.exe
WARNING: can't process DATA/pysqlite2-doc/default.css
WARNING: can't process DATA/pysqlite2-doc/docutils.css
WARNING: can't process DATA/pysqlite2-doc/install-source.txt
creating 'c:\docume~1\yan-ch~1.che\locals~1\temp\easy_install-5wz15q\pysqlite-2.5.6-py2.6-win32.egg' and adding 'c:\docume~1\ya
n-ch~1.che\locals~1\temp\easy_install-5wz15q\pysqlite-2.5.6-py2.6-win32.egg.tmp' to it
Moving pysqlite-2.5.6-py2.6-win32.egg to c:\python26\lib\site-packages
Adding pysqlite 2.5.6 to easy-install.pth file
Installed c:\python26\lib\site-packages\pysqlite-2.5.6-py2.6-win32.egg
Processing dependencies for pysqlite
Finished processing dependencies for pysqlite
However, I fail to install psycopg
C:\>c:\Python26\Scripts\easy_install.exe psycopg
Searching for psycopg
Reading http://pypi.python.org/simple/psycopg/
Reading http://initd.org/projects/psycopg1
Best match: psycopg 1.1.21
Downloading http://initd.org/pub/software/psycopg/psycopg-1.1.21.tar.gz
Processing psycopg-1.1.21.tar.gz
error: Couldn't find a setup script in c:\docume~1\yan-ch~1.che\locals~1\temp\easy_install-recnw8\psycopg-1.1.21.tar.gz
Is there other alternative?
Thanks!
The psycopg PyPi posting does not contain a pre-built w32 installer that easy_install can use nor could it find a way to build from source.
Here are some pre-built versions of the psycopg module.
easy_install only knows how to install modules distributed with the Python standard distribution and packaging solution called distutils. Psycopg is not. Psycopg is instead installed with the so called CMMI dance: configure/make/make install. Doing that on Windows is tricky, hence, you need to download a precompiled version, see Christians answer.