while using import soundfile on wither python3 or python I am getting:
Traceback (most recent call last):
File "", line 1, in
File "/home/erezsh/.local/lib/python3.6/site-packages/soundfile.py", line 142, in
raise OSError('sndfile library not found')
OSError: sndfile library not found
I found this post which did not help because I am using soundfile and not pysoundfile and the link it offers is broken.
Also, here I could not find a solution since I have installed using pip install SoundFile.
I am using Ubuntu shell on windows. Is this of any importance?
How do I solve this?
You need to install the needed library:
On Linux, you need to install libsndfile using your distribution’s package manager, for example sudo apt-get install libsndfile1.
From PyPI
handras answer (from 2019) is not working now (in 2020) so install libsndfile1 via ( as A.B.)
sudo apt-get install libsndfile1-dev
Try using the conda installation is you do not have sudo priviliges.
It worked for me, while I continued to face issues via the pip installation.
conda install -c conda-forge librosa
The above command installs librosa. You might be able to find a specific one for only soundfile too.
UPDATE: Needed to run apt update first, and it worked.
The accepted answer at first did not work for me.
I'm inside a docker image:
apt-get install libsndfile1
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libsndfile1
in case of yum package manager users first install the dependency
sudo yum -y install libsndfile
afterwards run the pip installs
pip install SoundFile
pip install librosa
Related
I have Python 2.6 in my Linux rhel-5. I have installed pip and required CFFI packages. When I try to run a sample CFFI program:
ffi = FFI()
it says:
File "/usr/lib/python2.6/site-packages/cffi/api.py", line 56, in __init__
import _cffi_backend as backend
ImportError: No module named _cffi_backend
What could be the possible error? Did I miss something during installation? I have installed pip, wheel, pycparser, pytest and cffi.
For python2.x use following command:
python -m pip install cffi
for python3.x
python3 -m pip install cffi
I needed to uninstall and install it again:
sudo pip uninstall cryptography
sudo pip uninstall paramiko
then install pagamiko again
sudo pip install paramiko
and it start to work for me
I recently had the same issue and none of the above solutions worked for me.
Here is what worked.
sudo apt remove python3-cffi
sudo python3 -m pip install cffi
Did you compile Python from source, and if so, did it give you any errors during the configure/make/make install phase? Compiling Python from source can be a real beast on older Red Hat systems, so if you installed that way, I'd suggest combing through the configure and make output to be sure that no modules were left out.
In order to get pip install cffi to succeed with no errors, I had to install gcc and libffi-devel from the EL5 repos. From there, I was able to instantiate an FFI instance with no problems:
>>> from cffi import FFI
>>> ffi = FFI()
>>>
Here's the output of pip freeze, for reference:
[root#machine ~]# pip freeze
argparse==1.2.1
autobahn==0.8.10
cffi==1.5.2
characteristic==14.3.0
pika==0.9.13
pyasn1==0.1.7
pyasn1-modules==0.0.8
pycparser==2.14
pycrypto==2.6.1
pyOpenSSL==0.12
pysnmp==4.2.5
requests==2.7.0
service-identity==14.0.0
six==1.7.3
Twisted==14.0.0
version-utils==0.2.2
wheel==0.24.0
zope.interface==4.1.1
If you've got the same or better versions of the relevant packages installed, I'd try a pip -vvv install --upgrade --force-reinstall cffi, just to see if there are perhaps errors that pip was masking, and go from there.
I had the same problem, following this thread https://github.com/pyca/cryptography/issues/4403, I solved the problem by reinstalling and upgrading with the command:
pip install -U cffi
You have to first remove the following packages:
cryptography
bcrypt
paramiko
Now use the following command to install:
pip -vvv install --upgrade --force-reinstall cffi
Have the same problem. After many attempts adding import cffi solve the issue.
Make sure you have cffi and cryptography installed.
You could look at the code L56 in /usr/lib/python2.6/site-packages/cffi/api.py
It needs the _cffi_backend.so in your pythonpath. You could install the python-cffi for it. But not sure whether it is in your RPM repo, especially you are using RHEL-5.
Here is an RPM for CENTOS http://cbs.centos.org/koji/rpminfo?rpmID=20613
Hope it helps. I am still searching the source code for building the _cffi_backend.so.
For me there was no way to install cffi on python3.8 because of this:
ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/__init__.py)
Somehow, the package python3-distutils does not exist in Ubuntu 16.04.
So I ended up installing python3.7 and now I finally could install cffi, fixing the problem mentioned by the TS.
You should install cffi via pip install cffi
to get the latest version. I had to restart my application for it to recognize the cffi installation.
I was getting this error while trying to get the cryptography module to work with Python 3.8 for AWS Lambda.
Adding the cffi*manylinux*.whl files to my Lambda Layer (as suggested here) worked.
The cffi module comes built in for many python distributions, but not on AWS Lambda
For AWS Lambda I was facing the same issue when running on Python3.7. When I downgraded it to Python3.6, this issue was resolved.
I think this packaged might have been present in Python3.6 version and later was removed. Adding this package while making layers for AWS Lambda might resolve the problem for Python3.7.
I encountered this issue when trying to install packages in a local directory using pip install -t . and then running python (2.7). My solution was to remove the -t and not install into a local directory.
it worked after adding " import cffi " in my application.
please refer for more details.
https://buildmedia.readthedocs.org/media/pdf/cffi/latest/cffi.pdf
Thanks to #MPlanchard, for his answer which helped identify the cause
In my case, the issue was related to python3.9, changing to python3.8 it just works well!
After many futile efforts to install the right packages, the right python versions and building the perfect layer, resorting to installing Fabric solved it for me
I got this issue running an Ansible playbook using python 3.9 under Ubuntu-18.04 in WSL2. It was sorted by doing:
sudo apt-get remove -y python3-cffi-backend
sudo apt-get install -y python3-cffi-backend
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!
For MacOS users
After trying all the above methods (which did not work for me on MacOS 10.14), that one worked :
Install openssl with brew install openssl if you don't have it already.
add openssl path to LIBRARY_PATH :
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
install psycopg2 with pip pip3 install psycopg2
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
I was also getting same error.
Using Python 3.7.3 and pip 19.1.1.
I used following command.
pip install psycopg2-binary==2.8.3
TDLR
If you aren't used to installing Python C-extensions, and psycopg2 isn't a core part of your work, try
pip install psycopg2-binary
Building Locally
psycopg2 is a C-extension, so it requires compilation when being installed by pip. The Build Prerequisites section of the docs explain what must be done to make installation via pip possible. In summary (for psycopg 2.8.5):
a C compiler must be installed on the machine
the Python header files must be installed
the libpq header files must be installed
the pg_config program must be installed (it usually comes with the libpq headers) and on $PATH.
With these prerequisites satisfied, pip install psycopg2 ought to succeed.
Installing pre-compiled wheels
Alternatively, pip can install pre-compiled binaries so that compilation (and the associated setup) is not required. They can be installed like this:
pip install psycopg2-binary
The docs note that
The psycopg2-binary package is meant for beginners to start playing with Python and PostgreSQL without the need to meet the build requirements.
but I would suggest that psycopg2-binary is often good enough for local development work if you are not using psycopg2 directly, but just as a dependency.
Concluding advice
Read the informative installation documentation, not only to overcome installation issues but also to understand the impact of using the pre-compiled binaries in some scenarios.
I had same problem and this appears to be a Mojave Issue, I was able to resolve with:
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
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
For MacOS users, this question has the correct solution:
install command line tools if necessary:
xcode-select --install
then
env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install psycopg2
I was also facing the same after running all the above commands, but the following two commands worked for me:
Instead of pip, use this:
sudo apt-get install libpq-dev
then run this command:
pip install psycopg2
On OS X, I was able to solve this by simply upgrading wheel before installing psycopg2:
pip install --upgrade wheel
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?
I tried all the above solutions but they did not work for me. What I did was change the psycopg2 version in my requirements.txt file from psycopg2==2.7.4 to psycopg2==2.7.6
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.
I faced the same issue, but the answers above didn't work for me.
So this is what I did in my requirements.txt
psycopg2-binary==2.7.6.1 and it worked fine
I had this issue on several packages, including psycopg2, numpy, and pandas. I simply removed the version from the requirements.txt file, and it worked.
So instead of psycopg2-binary==2.7.6.1 I just had psycopg2-binary.
I know you are asking for development environment but if you are deploying on server say, Heroku. Just add below line in the requirements.txt of your project.
django-heroku==0.3.1
As this package itself will install the required packages like psycopg2 on server deployment.So let the server(heroku) should take care of it.
sudo apt install libpq-dev python3.X-dev
where X is the sub version,
these should be followed by :
pip install --upgrade wheel
pip install --upgrade setuptools
pip install psycopg2
Enjoy !!!
I solved my problem by updating/installing vs_BuildTools. The link to the software was given in the error itself.
Error Image
Fixed by installing python3.7-dev: sudo apt install python3.7-dev, based on the link.
Python: 3.7
Ubuntu: 20.04.3 LTS
I am trying to install pyzipcode package using
pip install pyzipcode
I have a list of lat,lon data from which I require the Zipcodes. I checked online and pyzipcode came across as the most dependable solution for python. While trying to install I get the error below:
In file included from src/module.c:24:0:
src/connection.h:33:21: fatal error: sqlite3.h: No such file or directory
compilation terminated.
error: command 'Anac\Scripts\gcc.bat' failed with exit status 1
Also there are other results with same errors but haven't found any solution from those.
P.S: Any other way to get ZIPCODES in python from lon,lat will be helpful in the meantime
I encountered the same problem when installing pyzipcode on EC2 linux. Solved the issue by sudo yum install sqlite-devel before pip install pyzipcode==1.0. On Ubuntu or other system, it could be sudo apt-get install sqlite-dev or so.
From the error. It is expected to install sqlite3 in the system.
Install sqlite3 in ubuntu system with this command:
sudo apt-get install sqlite3
sudo apt-get install libsqlite3-dev
In mac use brew:
brew install sqlite3
In windows follow these steps:
Go to SQLite3 download page, “Precompiled Binaries For Windows”
section
Download “sqlite-shell” and “sqlite-dll” archive files
Unpack them and set environmental path (i.e., C:\program_files\sqlite3)
Install the sqlite3 Ruby gem.
I am trying to install tables package in Ubuntu 14.04 but sems like it is complaining.
I am trying to install it using PyCharm and its package installer, however seems like it is complaining about HDF5 package.
However, seems like I cannnot find any hdf5 package to install before tables.
Could anyone explain the procedure to follow?
I found that installing the libhdf5-serial-dev with
sudo apt-get install libhdf5-serial-dev
did the trick.
Search for the HDF5 library in the ubuntu package repository.
apt-cache search hdf5
The command will show the packages relating to hdf5.
install the relevant package to you.
sudo apt-get install package-name.
mostly you have to install the hdf5-tools, h5utils, python-tables.
Try to install libhdf5-7 and python-tables via apt
To be more precise, do two steps on Ubuntu
1) install hdf5
sudo apt-get install libhdf5-serial-dev
2) install pytables
pip install tables
I just got some space on a VPS server(running on ubuntu 8.04), and I'm trying to install django on it. The server has python 2.5 installed, but I guess its non standard installation. When I run install script for django, I get
amitoj#ninja:~/Django-1.2.1$ python setup.py install
Traceback (most recent call last):
File "setup.py", line 1, in <module>
from distutils.core import setup
ImportError: No module named distutils.core
I'm stumped. All the articles on internet tell me how to install modules using distutils. But how do I get distutils itself? Can anyone point me to the archive for distutils? I looked in /usr/lib/local/python2.5, /usr/lib/python2.5 etc, and as expected there is no distutils to be found.
I know this is an old question, but I just come across the same issue using Python 3.6 in Ubuntu, and I am able to solve it using the following command (this works in Ubuntu 18.04, 20.04 and 22.04):
sudo apt-get install python3-distutils
If you are unable to install with either of these:
sudo apt-get install python-distutils
sudo apt-get install python3-distutils
Try this instead:
sudo apt-get install python-distutils-extra
Ref: https://groups.google.com/forum/#!topic/beagleboard/RDlTq8sMxro
you can use sudo apt-get install python3-distutils by root permission.
i believe it worked here
You can install the python-distutils package. sudo apt-get install python-distutils should suffice.
I ran across this error on a Beaglebone Black using the standard Angstrom distribution. It is currently running Python 2.7.3, but does not include distutils. The solution for me was to install distutils. (It required su privileges.)
su
opkg install python-distutils
After that installation, the previously erroring command ran fine.
python setup.py build
The simplest way to install setuptools when it isn't already there and you can't use a package manager is to download ez_setup.py and run it with the appropriate Python interpreter. This works even if you have multiple versions of Python around: just run ez_setup.py once with each Python.
Edit: note that recent versions of Python 3 include setuptools in the distribution so you no longer need to install separately. The script mentioned here is only relevant for old versions of Python.
The module not found likely means the packages aren't installed.
Debian has decided that distutils is not a core python package, so it is not included in the last versions of debian and debian-based OSes. You should be able to do
sudo apt-get install python3-distutils
sudo apt-get install python3-apt
If you are in a scenario where you are using one of the latest versions of Ubuntu (or variants like Linux Mint), one which comes with Python 3.8, then you will NOT be able to have Python3.7 distutils, alias not be able to use pip or pipenv with Python 3.7, see:
How to install python-distutils for old python versions
Obviously using Python3.8 is no problem.
This didn't work for me: sudo apt-get install python-distutils
So, I tried this: sudo apt-get install python3-distutils
If the system Python is borked (i.e. the OS packages split distutils in a python-devel package) and you can’t ask a sysadmin to install the missing piece, then you’ll have to install your own Python. It requires some header files and a compiler toolchain. If you can’t have those, try compiling a Python on an identical computer and just copying it.
By searching all python-distutils related package:
apt-cache search x
I get python3-distutils-extra - enhancements to the Python3 build system
Then just try:
sudo apt-get install python3-distutils-extra