0

I'm using Debian 10 buster with python3.4 as the default python version.

sridharrajs@debian:~/Desktop/repos/demo$ python3 --version
Python 3.4.2

For one of my new projects I want to use python3.7.

sridharrajs@debian:~/Desktop/repos/demo$ python3.7 --version
Python 3.7.3

When I create a virtual environment, it fails with AttributeError: module 'posix' has no attribute '__all__'

sridharrajs@debian:~/Desktop/repos/demo$ virtualenv -p python3.7 venv
Running virtualenv with interpreter /usr/local/bin/python3.7
Fatal Python error: initsite: Failed to import the site module
Traceback (most recent call last):
  File "/usr/lib/python3.7/os.py", line 42, in _get_exports_list
    return list(module.__all__)
AttributeError: module 'posix' has no attribute '__all__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.7/site.py", line 79, in <module>
    import os
  File "/usr/lib/python3.7/os.py", line 65, in <module>
    __all__.extend(_get_exports_list(posix))
  File "/usr/lib/python3.7/os.py", line 44, in _get_exports_list
    return [n for n in dir(module) if n[0] != '_']
SystemError: <built-in function dir> returned NULL without setting an error

I tried Ubuntu 'Failed to import the site module' error message, Python 3 virtualenv problems, Using Python 3 in virtualenv

Sridhar
  • 11,466
  • 5
  • 39
  • 43
  • Have a look at this https://stackoverflow.com/questions/42214414/this-package-should-not-be-accessible-on-python-3-when-running-python3/42214539#42214539 – curious_coder Oct 22 '19 at 16:41
  • How did you get python 3.4? Buster comes with 3.7 by default: https://packages.debian.org/buster/python3 – barti_ddu Oct 22 '19 at 16:44
  • @barti_ddu I was using debain 8 before upgrading, so got 3.4 as a part of that. When I upgraded to debian 10, got 3.7. But for some reason, 3.7 is not the default one. – Sridhar Oct 22 '19 at 17:00
  • IMHO, your python installation is a mess. **Make a system backup** and try upgrading python3 and virtualenv to relevant versions. Also ditch your local python3.7 installation (You seem to have python3.7 install at /usr/local). – barti_ddu Oct 22 '19 at 17:36
  • try with `which python3.7` (to check it you have a local version), check with `apt` if the upgrade was not successful, and repair. Ev. reinstall python – Giacomo Catenazzi Oct 23 '19 at 12:46

0 Answers0