5

I am rather new to Linux (Ubuntu) and installing (Python) packages. I'm having trouble with mkvirtualenv and can not solve it:

~$ mkvirtualenv mysite70
New python executable in mysite70/bin/python
Traceback (most recent call last):
  File "/usr/lib/python2.7/site.py", line 562, in <module>
    main()
  File "/usr/lib/python2.7/site.py", line 544, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 271, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 246, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 236, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 577, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 476, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/usr/lib/python2.7/sysconfig.py", line 355, in _init_posix
    raise IOError(msg)
IOError: invalid Python installation: unable to open /home/sietse/.virtualenvs/mysite70/local/include/python2.7/pyconfig.h (No such file or directory)
ERROR: The executable mysite70/bin/python is not functioning
ERROR: It thinks sys.prefix is u'/home/usr/.virtualenvs' (should be u'/home/usr/.virtualenvs/mysite70')
ERROR: virtualenv is not compatible with this system or executable

Did I install something wrong?

musicformellons
  • 12,283
  • 4
  • 51
  • 86
  • try running the `mk` command with `sudo`. lets make sure it is not a permission error like often is in linux. –  Feb 10 '14 at 22:31

3 Answers3

1

This is likely a permissions error with your current logged in user on the Linux machine.

Try

sudo mkvirtualenv mysite70

This will often prompt for the password of the root user.

If that does not work, you may want to look at the article below:

http://noelusion.com/2013/Fixing-the-mysterious-virtualenv-error-IOError-invalid-Python-installation/

But note, that the article is a hack on a fairly specific instance.

DanGar
  • 3,018
  • 17
  • 17
  • I did this and get:~$ sudo mkvirtualenv mysite70 sudo: mkvirtualenv: command not found – musicformellons Feb 11 '14 at 22:08
  • sudo can changed you $PATH variable on ubuntu. Check your $PATH variable after sudo. If it is not what you expect, follow the post below: http://stackoverflow.com/questions/257616/sudo-changes-path-why – DanGar Feb 12 '14 at 00:07
  • ...I do not know what to expect...just know that it gives "mkvirtualenv: command not found"... When I follow your link, I do and get: ~$ echo 'echo $PATH' | sh /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games and: ~$ echo 'echo $PATH' | sudo sh /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin This path seems ok to me!? Any idea why the command is not found? Did I install Python 'outside su domain' or something; how do I 'repair'? Thanks! – musicformellons Feb 12 '14 at 08:37
1

I think I messed up the installation. I reinstalled Ubuntu, virtualenv etc. It works fine now.

musicformellons
  • 12,283
  • 4
  • 51
  • 86
  • 1
    OK, but it would also probably work if you purged and reinstalled the relevant packages (python-virtualenv virtualenvwrapper), deleted the old .virtualenvs folder and created the virtualenv from scratch. – metakermit Jul 31 '14 at 08:30
-1

Make sure your username has accents or special characters. If yes, change directory creating environments creating an environment variable WORKON_HOME with value equal to the new path. Ex .: C:\Envs