ImportError: No module named 'gdbm' occuring while using source ~/.bashrc - python

Hey after making some changes in the bashrc I tried to use
source ~/.bashrc
but got the following error
baaz#FireStorm:~$ source ~/.bashrc
Traceback (most recent call last):
File "/usr/lib/python3.5/dbm/gnu.py", line 4, in <module>
from _gdbm import *
ImportError: No module named '_gdbm'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 7, in <module>
import dbm.gnu as gdbm
File "/usr/lib/python3.5/dbm/gnu.py", line 6, in <module>
raise ImportError(str(msg) + ', please install the python3-gdbm package')
ImportError: No module named '_gdbm', please install the python3-gdbm package
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 27, in <module>
from CommandNotFound.util import crash_guard
File "/usr/lib/python3/dist-packages/CommandNotFound/__init__.py", line 3, in <module>
from CommandNotFound.CommandNotFound import CommandNotFound
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 9, in <module>
import gdbm
ImportError: No module named 'gdbm'
I tried using the install commands as mentioned in the error
baaz#FireStorm:~$ sudo apt-get install python3-gdbm
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-gdbm is already the newest version (3.6.5-3~16.04.york0.2).
python3-gdbm set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Also some solutions mentioned to use version specific commands, but still got no solution
baaz#FireStorm:~$ sudo apt-get install python3.5-gdbm
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python3.5-gdbm is a virtual package provided by:
python3-gdbm 3.5.1-1 [Not candidate version]
E: Package 'python3.5-gdbm' has no installation candidate
The pip install command gave the following error
baaz#FireStorm:~$ sudo pip3 install gdbm --upgrade
The directory '/home/baaz/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/baaz/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting gdbm
Could not find a version that satisfies the requirement gdbm (from versions: )
No matching distribution found for gdbm
Please suggest a way to sort out these error.

Your error is occurring most likely because your .bashrc contains a typo somewhere, therefore command-not-found is being called, but command-not-found appears to have been recently broken. (You should get the same error if you type some nonsense into your terminal directly.)
sudo apt install python3-gdbm=3.5.1-1
worked for me.
From running
dpkg -L python3-gdbm
it looked like gdbm on my computer is being installed to python3.6 for some reason, not python3.5, but my python3 version is python3.5 (and last I checked python3.6 breaks something on ubuntu 16.04).
The error you got when you ran
sudo apt-get install python3.5-gdbm
complained about a version issue, hence manually installing the version they noted worked.

This worked for me:
sudo ln -s /usr/lib/python3.6/lib-dynload/_gdbm.cpython-36m-x86_64-linux-gnu.so /usr/lib/python3.5/lib-dynload/_gdbm.cpython-35m-x86_64-linux-gnu.so
Note the 35m in the the link's name.

Related

pip install FileNotFoundError: [Errno 2] No such file or directory:

I am trying to install behave-parallel using pip install. I have installed programmes previously using pip so I know my Python/script path is correct in my env variables. However I am seeing the following error
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\.....Temp\\pip-install-rjiorrn7\\behave-parallel\\setup.py'
how can I resolve this issue
C:\Users\.....>pip install behave-parallel
Collecting behave-parallel
Using cached https://files.pythonhosted.org/packages/05/9d/22f74dd77bc4fa85d391564a232c49b4e99cfdeac7bfdee8151ea4606632/behave-parallel-1.2.4a1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\.........\python\lib\tokenize.py", line 447, in open
buffer = _builtin_open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\.........\\AppData\\Local\\Temp\\pip-install-7vgf8_mu\\behave-parallel\\setup.py'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\.........\AppData\Local\Temp\pip-install-7vgf8_mu\behave-parallel\
In my case with the same error, the solution was to do
pip3 install --upgrade pip
It was my pip3 that was in version 9.X were it's now in version 19.X
The package is simply broken, as it is missing the setup.py file.
$ tar tzvf behave-parallel-1.2.4a1.tar.gz | grep setup.py
$
You might be able to download the source from Github or wherever and package it yourself (python setup.py bdist_wheel), then install that wheel (pip install ../../dist/behave-parallel...whl).
There is a newer feature for building python packages (see also PEP 517 and PEP 518). A package can now be built without setup.py (with pyproject.toml), but older pip versions are not aware of this feature and raise the error shown in the question.
So if you have reason to believe that the library was packaged properly, try updating pip to something newer (version 19 or newer will probably work).
Here it seems caused by setup.py not being in the root of my project.
(it can't be in root because otherwise the unit test will "discover" setup.py and fail it because it's not a test)

Emacs deferred errors

I have installed the Emacs package jedi-emacs using M-x package install
and the following Python packages:
Jedi
EPC
argparse
using:
pip install --install-option="--prefix=~/.my_python_packages/" jedi
pip install --install-option="--prefix=/.my_python_packages/" epc
pip install --install-option="--prefix=/.my_python_packages/" argparse
since I do not have root priviledges.
When I open a Python file, I get the following error in the minibuffer, no matter where I place the cursor:
deferred error : (error Server may raise an error : Traceback (most recent call last):
File "/home/avazquez/.emacs.d/elpa/jedi-20130119.830/jediepcserver.py", line 261, in <module>
)
What could be causing it?
This is with Emacs 24.2.1
I found the solution to my problem. I did not have PYTHONPATH set up correctly (it should include the corresponding paths for /path/to/custom-packages).
For more info on this issue see the corresponding ticket in the package repository for emacs-jedi.

hdf5 / h5py ImportError: libhdf5.so.7

I'm working on a project involving network messaging queues (msgpack, zmq, ...) on a RHEL 6.3 (x86_64) system. I was installing the most recent packages of glib, gevent, pygobject, pygtk, and such in order to get pylab / matplotlib to work (which hasn't been successful either).
After giving up I went back to my code and somehow I had managed to wreck my hdf5 / h5py installation - h5py can't find libhdf5.so.7 on import. I immediately reinstalled hdf5-1.8.9 in /usr/local/hdf5 on RHEL 6.3 (x86_64) as follows:
./configure --prefix=/usr/local/hdf5
make
make check
sudo make install
make check install
which seemed to work just fine. Then I went to reinstall h5py (in python 2.7.3):
python2.7 setup.py build --hdf5=/usr/local/hdf5/
python2.7 setup.py test # optional
# sudo python2.7 setup.py install
which fails to import the _errors file in the tests, like so:
======================================================================
ERROR: _hl.tests.test_attrs_data (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: _hl.tests.test_attrs_data
Traceback (most recent call last):
File "/usr/local/lib/python2.7/unittest/loader.py", line 252, in _find_tests
module = self._get_module_from_name(name)
File "/usr/local/lib/python2.7/unittest/loader.py", line 230, in _get_module_from_name
__import__(name)
File "/home/cronburg/Downloads/h5py-2.0.1/build/lib.linux-x86_64-2.7/h5py/_hl/tests/test_attrs_data.py", line 5, in <module>
import h5py
File "/home/cronburg/Downloads/h5py-2.0.1/build/lib.linux-x86_64-2.7/h5py/__init__.py", line 1, in <module>
from h5py import _errors
ImportError: libhdf5.so.7: cannot open shared object file: No such file or directory
----------------------------------------------------------------------
Ran 12 tests in 0.001s
FAILED (errors=12)
h5py was working fine before I went to install the aforementioned packages / tarballs, and I don't remember touching anything that even remotely looked like hdf5. Any ideas?
EDIT:
Trying to locate the file only shows it in the location i untarred it:
cronburg#rhel:~/Downloads/h5py-2.0.1$ locate libhdf5.so.7
/home/cronburg/tmp/hdf5-1.8.9/hdf5/lib/libhdf5.so.7
/home/cronburg/tmp/hdf5-1.8.9/hdf5/lib/libhdf5.so.7.0.3
/home/cronburg/tmp/hdf5-1.8.9/src/.libs/libhdf5.so.7
/home/cronburg/tmp/hdf5-1.8.9/src/.libs/libhdf5.so.7.0.3
take a look on:
http://rpm.pbone.net/index.php3/stat/3/srodzaj/1/search/libhdf5.so.7()(64bit)
Or should try this repo: https://ius.io/Packages/
I prefer always use the most updated python version, in a package format.
https://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/repoview/python27.html
sudo yum install -y https://centos6.iuscommunity.org/ius-release.rpm
sudo yum install -y python27
sudo yum install -y python27-devel
Do a pip install and be happy:
$ sudo pip install h5py
Installing collected packages: h5py
Successfully installed h5py-2.6.0
This also happened to me when using h5py on a clean raspbian. You need to install the system libraries first.
apt install libhdf5-dev
then
pip install h5py

Easy_install and Pip doesn't work

Easy_install and Pip doesn't work anymore on python 2.7, when I try to do:
sudo easy_install pip
I get:
Traceback (most recent call last):
File "/usr/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 2713, in <module>
parse_requirements(__requires__), Environment()
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 584, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: distribute==0.6.15
And when I try:
sudo pip install [package]
I get:
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 2713, in <module>
parse_requirements(__requires__), Environment()
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 584, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==0.8.2
I've already install both of them (and yes, first deleted them), but no result...
Thanks!
(I tried already this post)
I had this issue where python's distribute package wasn't installed for some reason. After following the instructions on python-distribute, i got it working.
install the distribute package as follows:
$ wget https://web.archive.org/web/20100225231201/http://python-distribute.org/distribute_setup.py
$ python distribute_setup.py
EDIT: http://python-distribute.org/distribute_setup.py no longer works:
hopefully this will resolve your problem with running
$ sudo easy_install
Happy Coding!
If you installed a new version of easy_install through Distribute, the new command may have been installed in another directory, most likely /usr/local/bin/. But the traceback shows you were using /usr/bin/easy_install. Try this:
sudo /usr/local/bin/easy_install ...
Try
sudo easy_install Distribute
and if that exists, but is too old
sudo easy_install -U Distribute
Looks like either Distribute/setuptools (it's old name) is messed up or Python package settings. If either of these do not help, try removing the full Python 2.7 installation and reinstall everything from the scratch.
Possible reasons for the mess is that you have used both sudo easy_install / sudo pip and Linux distribution packages to mix and match system-wide installation packages. You should use virtualenv instead if you use pip/easy_install (no sudo needed)
http://pypi.python.org/pypi/virtualenv
I had a similar problem, but things were working fine as root. In my case, I found that the permissions on the python packages were not readable by the ID I was running the command under.
To correct it, I ran the following command to open the permission for read and execute to all users:
sudo chmod o+rx -R /usr/local/lib/python2.7/dist-packages/*.egg
I had similar issue when trying to install package via pip with python 3.6 on windows. (pip is supposed to work out of the box with this install)
The problem was not running as administrator.
Running cmd as administrator and then installing my package worked:
python -m pip install pylint
I was trying to get pip to work on the 2.7.0 version, but it seems like it doesn't come with the easy_install/pip files (Script folder in main directory), installing 2.7.13 solved the problem for me.

pip install PyQt IOError

I'm trying to install PyQt package with pip, but I get this error:
~$ pip install PyQt
Downloading/unpacking PyQt
Downloading PyQt-x11-gpl-4.8.3.tar.gz
(9.8Mb): 9.8Mb downloaded Running
setup.py egg_info for package PyQt
Traceback (most recent call last):
File "<string>", line 14, in <module>
IOError: [Errno 2] No such file or directory:
'/home/john/build/PyQt/setup.py'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 14, in
<module>
IOError: [Errno 2] No such file or
directory:
'/home/john/build/PyQt/setup.py
---------------------------------------- Command python setup.py egg_info
failed with error code 1 Storing
complete log in
/home/john/.pip/pip.log
That's because that file has a configure.py not a setup.py. configure.py generate a make file that you use to build pyqt against the qt lib you choose by passing --qmake option to configure.py, it has different options too. I suggest filing a bug with the pip maintainer.
If you're on Mac, you can use homebrew:
brew install pyqt
You can, alternatively, install PyQt4 using ActivePython's binary package manager.
$ pypm install pyqt4
The following packages will be installed into "~/.local" (2.7):
pyqt4-4.8.3.0
Hit: [pypm-free.activestate.com] pyqt4 4.8.3.0
Installing pyqt4-4.8.3.0
$
So long as you already have PyPM, no compilation required.
Sharing my setup procedure:
create virtual environment on your project folder and activate:
python3 -m venv venv
source venv/bin/activate
use pip to install PyQt5 (Note: specify the version especially on Centos7)
pip3 install pyqt5==5.14
you can pip install the directory of the downloaded version of pyqt after you download it ..google for your desired version

Categories