現象
(venv) $ python3.5 -v import _frozen_importlib # frozen import _imp # builtin import sys # builtin import '_warnings' # <class '_frozen_importlib.BuiltinImporter'> import '_thread' # <class '_frozen_importlib.BuiltinImporter'> import '_weakref' # <class '_frozen_importlib.BuiltinImporter'> import '_frozen_importlib_external' # <class '_frozen_importlib.FrozenImporter'> import '_io' # <class '_frozen_importlib.BuiltinImporter'> import 'marshal' # <class '_frozen_importlib.BuiltinImporter'> import 'posix' # <class '_frozen_importlib.BuiltinImporter'> import _thread # previously loaded ('_thread') import '_thread' # <class '_frozen_importlib.BuiltinImporter'> import _weakref # previously loaded ('_weakref') import '_weakref' # <class '_frozen_importlib.BuiltinImporter'> (略) import 'site' # <_frozen_importlib_external.SourceFileLoader object at 0x767f7790> Python 3.5.8 (default, Dec 14 2019, 09:32:39) [GCC 6.3.0 20170516] on linux Type "help", "copyright", "credits" or "license" for more information. import 'atexit' # <class '_frozen_importlib.BuiltinImporter'>
調査
$ ls bin/python3.5 -l lrwxrwxrwx 1 syoshida syoshida 18 Jan 19 2019 bin/python3.5 -> /usr/bin/python3.5 $ ls /usr/bin/python3.5 $ which python3.5 /usr/local/bin/python3.5
deadシンボリックリンクを消して修復(消さないと Error: [Errno 2] No such file or directory: 'env3.5/bin/python3.5')
$ cd bin $ rm python* $ python3.5 -m venv env3.5 $ . env3.5/bin/activate $ python -V Python 3.5.8
参考
Fixing virtualenv after Upgrading Your Distribution/Python
https://www.guyrutenberg.com/2012/05/30/fixing-virtualenv-after-upgrading-your-distributionpython/
(depending on how you created it in the same place). All the modules you’ve already installed should keep working as before (at least it was that way for me).
分かる