How to Solve Error virtualenv is not compatible with this system or executable

Posted on

This is an article written to solve the error specified in the title. It is actually an error where the error itself happened upon executing the command ‘virtualenv virtual_environment_name’ as shown below :

root@hostname:/home/user/apps/user# virtualenv projectenv
New python executable in /home/user/apps/user/projectenv/bin/python
Traceback (most recent call last):
  File "/usr/lib/python2.7/site.py", line 563, in 
    main()
  File "/usr/lib/python2.7/site.py", line 545, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 272, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 247, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 237, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 582, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 528, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/usr/lib/python2.7/sysconfig.py", line 412, in _init_posix
    from _sysconfigdata import build_time_vars
  File "/usr/lib/python2.7/_sysconfigdata.py", line 6, in 
    from _sysconfigdata_nd import *
ImportError: No module named _sysconfigdata_nd
ERROR: The executable /home/user/apps/user/projectenv/bin/python is not functioning
ERROR: It thinks sys.prefix is u'/home/user/apps/user' (should be u'/home/user/apps/user/projectenv')
ERROR: virtualenv is not compatible with this system or executable
root@hostname:/home/user/apps/user# 

The error is shown as follows :

ERROR: virtualenv is not compatible with this system or executable

The virtual environment basically assumed as the aspect needed to be included in the configuration of Apache Webserver in order to deploy a web-based application powered by Django framework written in Python programming language. The following is considered to be the value of the path where the virtual environment created in Apache Webserver virtual host configuration :

WSGIPythonHome /home/user/apps/user/projectenv

To solve the problem, create a symlink to the python home folder location currently running by executing the following command :

root@hostname:/home/user/apps/user# ln -fs /usr/lib/python2.7/plat-x86_64-linux-gnu/_sysconfigdata.py /usr/lib/python2.7/
root@hostname:/home/user/apps/user# sudo ln -fs /usr/lib/python2.7/plat-x86_64-linux-gnu/_sysconfigdata_nd.py /usr/lib/python2.7/

After executing the command line above, just re-execute the command used to create a virtual environment as shown below :

root@hostname:/home/user/apps/user# virtualenv projectenv
New python executable in /home/user/apps/user/projectenv/bin/python
Installing setuptools, pip, wheel...done.
root@hostname:/home/user/apps/user#

After that, check the content of the folder inside where the command for creating the virtual environment is executed, just to make sure as shown below :

root@hostname:/home/user/apps/user# ls
bin  projectenv  app.sublime-project  app.sublime-workspace  include  lib  local  logs  src  static
You have new mail in /var/mail/root
root@hostname:/home/user/apps/user# 

Leave a Reply