install HDF5 and pytables in ubuntu - python

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

Related

ModuleNotFoundError : No module named 'psycopg2._psycopg'

I am using imports :-
import psycopg2
But while running the code in local, I am facing an issue of :-
from psycopg2._psycopg import (
ModuleNotFoundError: No module named 'psycopg2._psycopg'
I have installed psycopg2 using cmd [pip install psycopg2]
psycopg2 version 2.8.4
python version 3.7.3
python 3.7 32bit
How should I import the ._psycopg.py file in windows? or any other solution if possible?
I'm also facing the same problem. It took me 2 days to pulled out my hair until I found the solution.
What I've been tried
Here's what I have been doing to solve this issue BUT DIDN'T SOLVE THE PROBLEM. I hope it will help anybody else who has the same problem.
Install "psycopg2" and "psycopg2-binary"
pip install psycopg2
pip install psycopg2-binary
Install "libpq-dev"
sudo apt install libpq-dev
Install "python-psycopg2" and "python3-psycopg2"
sudo apt install python-psycopg2 python3-psycopg2
Install "python-dev" and "python3-dev" and "python3.9-dev"
sudo apt install python-dev python3-dev python3.9-dev
Install "python-setuptools"
sudo apt install python-setuptools
Unfortunately, none of my effort above solve my problem.
What's the solution
So, here's my solution that I've been try and IT WORKS
Install the latest mod_wsgi from Github.
You should install this latest 'mod_wsgi' in order to your wsgi able to use Psycopg2 library. Here's my step to do it :
Go to release page mod_wsgi on Github (https://github.com/GrahamDumpleton/mod_wsgi/releases)
Download the file from latest version. As I write this, the latest version is 4.7.1 (https://github.com/GrahamDumpleton/mod_wsgi/archive/4.7.1.tar.gz)
Follow the installation guide from official docs.
Unpacking source code
tar xvfz mod_wsgi-4.7.1.tar.gz
Configure source code
./configure
Build the source code and install
make
make install
Restart apache server
sudo service apache2 restart
This solution has works on my machine (Ubuntu 18.04 & Python 3.9 Venv).
Alternative solution
Here's some solution from others.
Saray Chak's solution

Can't import soundfile python

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

Unable to install matplotlib for Python 3

I'm using JetBrains PyCharm Community Edition 2016.3.2 (64). My Project Interpreter is either Python 3.4 or 3.5. I'm trying to install the Matplotlib package but failed every time. I succeeded on installing Networkx though.
On this site https://networkx.github.io/documentation/networkx-1.10/tutorial/tutorial.html, in the "Drawing graphs" section, it says
Note that the drawing package in NetworkX is not yet compatible with Python versions 3.0 and above.
Someone please confirm this? Should I install Python 2.x to use this package?
I'm doing graph modelling, if anyone can suggest other packages or advise whatever I should use, I would really appreciate. But it needs to be related to Networkx.
Regarding Matplotlib, I don't see why the installation would fail.
try:
sudo apt-get install python3-matplotlib
Depending on your installation, you'll also have to install several libraries that matplotlib depends on:
sudo apt-get install python3.5-dev python3.5-tk tk-dev
sudo apt-get install libfreetype6-dev g++
sudo apt install python3-pip
pip3 install --user matplotlib
In addition, you will need one other package - nose. You can install it using the same syntax:
sudo pip3 install nose
Networkx installation is simple as:
sudo pip3 install networkx
Good luck!

"Failed building wheel for psycopg2" - MacOSX using virtualenv and pip

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

import Error: No Module named cropresize

I am new to python. I am working on some other's project but when i tried to run the code it give me the error said above. My all pages are working properly except those in which i had images. Is there any library required for the same??
Any help will be appreciable.
Thanks
you need to have cropresize package http://pypi.python.org/pypi/cropresize/ installed on your device.
If it is not there install it from the link
Do easy_install cropresize or pip install cropresize
Just do easy_install cropresize.
cropresize package needs to be installed! First install pip(Ubuntu/Debian):
sudo apt-get install python-pip
Then install cropresize using pip:
pip install cropresize
cropresize (all versions) depends on PIL.
Unfortunately, Pillow (installed) does not satisfy this dependency when using pip or easy_install :(

Categories