4

Once I made my virtualenv, Python was already installed. How do I add the option --enable-shared? Do I delete it or start virtualenv over from fresh? If I do that, how do I add the Python option? I don't want to mess anything up.

User
  • 23,729
  • 38
  • 124
  • 207

1 Answers1

5

When you create a virtual environment, the Python binaries will be copied, not compiled. Quoting from the venv documentation,

It also creates a bin (or Scripts on Windows) subdirectory containing a copy of the python binary (or binaries, in the case of Windows)

But --enable-shared is an option for the ./configure script, which is used during compilation of the Python from source code.

So, you first have to compile Python from the source code, with --enable-shared option, and then create virtual environment with the compiled python binary.

If you are using unix based OS, then by default, the installation will happen in /usr/local directory, so that you will not mess up with the current Python installation.

Moreover, instead of sudo make install, use sudo make altinstall. This will install the Python with the major.minor version format.

Maxime Lorant
  • 34,607
  • 19
  • 87
  • 97
thefourtheye
  • 233,700
  • 52
  • 457
  • 497