Anaconda does not find any module after Ubuntu upgrade to 18.04 - python

After upgrading my Ubuntu OS from 16.04 LTS to 18.04.4 LTS, my python anaconda distribution does not find any regular module that should be in anaconda (numpy, matplotlib...), for instance, starting python from the command shell:
pjacquot#HP-EliteBook-Folio-1040-G3:python
Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:51:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'matplotlib'
>>>
I can not even start spyder:
pjacquot#HP-EliteBook-Folio-1040-G3:~$ spyder
Traceback (most recent call last):
File "/home/pjacquot/anaconda3/bin/spyder", line 7, in <module>
from spyder.app.start import main
ModuleNotFoundError: No module named 'spyder'
I checked that I was using the "good" python:
pjacquot#HP-EliteBook-Folio-1040-G3:which python
/home/pjacquot/anaconda3/bin/python
and that the directory is in my path:
pjacquot#HP-EliteBook-Folio-1040-G3: echo $PATH
/home/pjacquot/anaconda3/bin:/texlive/2017/bin/x86_64-linux
Any idea what's happened there ?
I can still re install all modules, but it's going around the bush as they should be somewhere around here...

The not-clever solution: delete old anaconda (sudo rm -rf anaconda3) and reinstall it from scratch (takes 3 minutes and works...).

Related

Python module **slackclient** installs correctly, but will not import ... is it known under another name?

I am trying to get a module slackclient installed in a virtual Python environment.
python3 -m venv slackenv
. slackenv/activate
pip3 install slackclient
I get
python3.7
Python 3.7.6 (default, Jan 12 2022, 23:27:58)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import slackclient
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'slackclient'
This is with slackclient installed both in the virtualenv and in the main system pip list. (It shows up in both lists).
What could be the issue?
Despite the name of the package is slackclient, the actual module is slack, as can you see in the official page of the package. So, try this one:
import slack
it should work.

How can I use globally installed CV2 (manual install) package into python virtual environment?

I have manually installed CV2 on Ubuntu box, and when I import CV2 it works perfectly.
If I create virtual environment (python -m venv myvenv), I am not able to use globally installed CV2.
Kindly advice the fix, to use global installed packages into python virtual environment.
Python 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2 as cv
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'
>>>

Importerror: No module named time in python2.7.6 in ubuntu

I have a strange problem on python2.7.6 with Ubuntu :
my python 2.7.6 is installed but strangely time module is not working. my ubuntu version is 16.04
i tried installing python 2.7.16 as well but that didnt fixed the issue as
/usr/local/bin# python2.7
Python 2.7.6 (default, Jul 22 2019, 12:49:04)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named time
expected : import time should work
actual : ImportError: No module named time
How do i import time in python 2.7.6
output of :
: ls /usr/lib/python2.7/lib-dynload/
audioop.i386-linux-gnu.so _codecs_tw.i386-linux-gnu.so dl.i386-linux-gnu.so _lsprof.i386-linux-gnu.so Python-2.7.egg-info
audioop.x86_64-linux-gnu.so _codecs_tw.x86_64-linux-gnu.so _elementtree.i386-linux-gnu.so _lsprof.x86_64-linux-gnu.so readline.i386-linux-gnu.so
_bsddb.i386-linux-gnu.so crypt.i386-linux-gnu.so _elementtree.x86_64-linux-gnu.so mmap.i386-linux-gnu.so readline.x86_64-linux-gnu.so
_bsddb.x86_64-linux-gnu.so crypt.x86_64-linux-gnu.so fpectl.i386-linux-gnu.so mmap.x86_64-linux-gnu.so resource.i386-linux-gnu.so
bz2.i386-linux-gnu.so _csv.i386-linux-gnu.so fpectl.x86_64-linux-gnu.so _multibytecodec.i386-linux-gnu.so resource.x86_64-linux-gnu.so
bz2.x86_64-linux-gnu.so _csv.x86_64-linux-gnu.so future_builtins.i386-linux-gnu.so _multibytecodec.x86_64-linux-gnu.so _sqlite3.i386-linux-gnu.so
_codecs_cn.i386-linux-gnu.so _ctypes.i386-linux-gnu.so future_builtins.x86_64-linux-gnu.so _multiprocessing.i386-linux-gnu.so _sqlite3.x86_64-linux-gnu.so
_codecs_cn.x86_64-linux-gnu.so _ctypes_test.i386-linux-gnu.so _hashlib.i386-linux-gnu.so _multiprocessing.x86_64-linux-gnu.so _ssl.i386-linux-gnu.so
_codecs_hk.i386-linux-gnu.so _ctypes_test.x86_64-linux-gnu.so _hashlib.x86_64-linux-gnu.so nis.i386-linux-gnu.so _ssl.x86_64-linux-gnu.so
_codecs_hk.x86_64-linux-gnu.so _ctypes.x86_64-linux-gnu.so _hotshot.i386-linux-gnu.so nis.x86_64-linux-gnu.so termios.i386-linux-gnu.so
_codecs_iso2022.i386-linux-gnu.so _curses.i386-linux-gnu.so _hotshot.x86_64-linux-gnu.so ossaudiodev.i386-linux-gnu.so termios.x86_64-linux-gnu.so
_codecs_iso2022.x86_64-linux-gnu.so _curses_panel.i386-linux-gnu.so imageop.i386-linux-gnu.so ossaudiodev.x86_64-linux-gnu.so _testcapi.i386-linux-gnu.so
_codecs_jp.i386-linux-gnu.so _curses_panel.x86_64-linux-gnu.so _json.i386-linux-gnu.so parser.i386-linux-gnu.so _testcapi.x86_64-linux-gnu.so
_codecs_jp.x86_64-linux-gnu.so _curses.x86_64-linux-gnu.so _json.x86_64-linux-gnu.so parser.x86_64-linux-gnu.so
_codecs_kr.i386-linux-gnu.so dbm.i386-linux-gnu.so linuxaudiodev.i386-linux-gnu.so pyexpat.i386-linux-gnu.so
_codecs_kr.x86_64-linux-gnu.so dbm.x86_64-linux-gnu.so linuxaudiodev.x86_64-linux-gnu.so pyexpat.x86_64-linux-gnu.so
It seems time package is not install, you can try by installing time package using below command.
pip install times
or
sudo pip install times.
and then try?

Cannot import any modules (installed used pip) in python 2.7.14

I downloaded the source code of python 2.7.14 and built it and installed it on linux ( Red Hat 4.8.5-16 ). I have earlier installed python-magic and requests libraries. Now when I try to import modules installed using pip, I get this:
$ python2
Python 2.7.14 (default, Nov 9 2017, 09:05:45)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import magic
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named magic
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named requests
while similar thing works perfectly fine in python 2.7.5 (default with the RHEL system)
$ python
Python 2.7.5 (default, May 3 2017, 07:55:04)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-14)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import magic
>>> import requests
>>>
Am I missing any configuration step here?
The modules installed via pip are only available to the standard python version. You need to install your desired packages for the non-standard python versions as well (see also Installing Python Modules)
python2 -m pip install python-magic
python2 -m pip install requests
your pip is default set for version
$ python
Python 2.7.5
SO if you want to install module for
$ python2
Python 2.7.14
use python2 -m pip install module_name
The sys.path must be different for the two installations. That's a list of folders that Python checks for imports.
It's probably simplest to just symlink the one for wherever pip installs to into the modules folder for 2.7.14.

How to install libgit2/pygit2 into virtualenv? (Ubuntu)

I have tried dulwich, and GitPython - neither of which seem mature. Now I am trying to install libgit2/pygit2. I have successfully installed them into the host packages environment, but now I need to get them installed in the virtualenv of the app I am building.
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygit2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/pygit2/__init__.py", line 32, in <module>
import _pygit2
ImportError: libgit2.so.0: cannot open shared object file: No such file or directory
>>>
As you can see the current issue seems to be that the globally installed libgit2.so.0 cannot be found from within the virtualenv. Fair enough, that is what virtualenv is about after all,, sandboxing. So how do I go about linking/symlinking/building a version/copy of the libgit2.so for the virtualenv ?
I found the following script in a Gist that - when run while logged into a virtualenv -- will install the current libgit2/pygit2 together there in the venv.
https://gist.github.com/olivier-m/5755638
One note of caution, update the version numbers for both libraries to the same most recent version ( 0.20.0 at this time of writing ).

Categories