Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Python
  4. Can you have a virtual environment based on a virtual environment?

Can you have a virtual environment based on a virtual environment?

Scheduled Pinned Locked Moved Python
questionworkspace
5 Posts 3 Posters 16 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chris Maunder
    wrote on last edited by
    #1

    We're curious. A virtual environment can use system wide resources, but can a virtual environment lean on an existing venv and only have the extra bits, or overide bits, that are specific to that new venv?

    cheers Chris Maunder

    T L 2 Replies Last reply
    0
    • C Chris Maunder

      We're curious. A virtual environment can use system wide resources, but can a virtual environment lean on an existing venv and only have the extra bits, or overide bits, that are specific to that new venv?

      cheers Chris Maunder

      T Offline
      T Offline
      trønderen
      wrote on last edited by
      #2

      I'm curious: Is any VM implementation programmed in Python? (Recursive virtualization or not!)

      1 Reply Last reply
      0
      • C Chris Maunder

        We're curious. A virtual environment can use system wide resources, but can a virtual environment lean on an existing venv and only have the extra bits, or overide bits, that are specific to that new venv?

        cheers Chris Maunder

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        The virtual environment just puts itself (i.e its version of Python and associated libraries) at the front of the search path. So anything called after you run activate, will load first from the .venv locations, before looking at the system folders. I guess that if you then activate another .venv then the search path would be venv2 -> venv1 -> system installation. Which could be fun.

        C 1 Reply Last reply
        0
        • L Lost User

          The virtual environment just puts itself (i.e its version of Python and associated libraries) at the front of the search path. So anything called after you run activate, will load first from the .venv locations, before looking at the system folders. I guess that if you then activate another .venv then the search path would be venv2 -> venv1 -> system installation. Which could be fun.

          C Offline
          C Offline
          Chris Maunder
          wrote on last edited by
          #4

          I guess I could do this manually, since it's only really the site-packages I'm worried about. Something like Suppose I have two apps that have different and potentially conflicting packages. I'd create a venv with the python interpreter in /app/bin/python and the common packages in /app/bin/python/site-packages-common. I'd then install specific packages for app A and B in different folders:

          /app/bin/python
          /app/bin/python/site-packages-common
          /app/bin/python/site-packages-A
          /app/bin/python/site-packages-B

          then in app A I could do ```python sys.path.insert(0, "/app/bin/python/site-packages-common") sys.path.insert(0, "/app/bin/python/site-packages-A") ``` and in app B I could do ```python sys.path.insert(0, "/app/bin/python/site-packages-common") sys.path.insert(0, "/app/bin/python/site-packages-B") ``` I would have to specify the target folder when running pip to install the packages (no drama). My big concern is if we have the following: ``` pip install common-package -target /app/bin/python/site-packages-common pip install package-a -target /app/bin/python/site-packages-A pip install package-b -target /app/bin/python/site-packages-B ``` What if package-a relies on v1 of common-package, and package-b relies on v2 of common-package? I'm actually assuming pip will install all dependent packages anyway, so while we might end up with repeated installs of dependant packages, there are certainly some 'common' packages that won't necessarily be dependencies of anything and so will only be installed once in the common folder

          cheers Chris Maunder

          L 1 Reply Last reply
          0
          • C Chris Maunder

            I guess I could do this manually, since it's only really the site-packages I'm worried about. Something like Suppose I have two apps that have different and potentially conflicting packages. I'd create a venv with the python interpreter in /app/bin/python and the common packages in /app/bin/python/site-packages-common. I'd then install specific packages for app A and B in different folders:

            /app/bin/python
            /app/bin/python/site-packages-common
            /app/bin/python/site-packages-A
            /app/bin/python/site-packages-B

            then in app A I could do ```python sys.path.insert(0, "/app/bin/python/site-packages-common") sys.path.insert(0, "/app/bin/python/site-packages-A") ``` and in app B I could do ```python sys.path.insert(0, "/app/bin/python/site-packages-common") sys.path.insert(0, "/app/bin/python/site-packages-B") ``` I would have to specify the target folder when running pip to install the packages (no drama). My big concern is if we have the following: ``` pip install common-package -target /app/bin/python/site-packages-common pip install package-a -target /app/bin/python/site-packages-A pip install package-b -target /app/bin/python/site-packages-B ``` What if package-a relies on v1 of common-package, and package-b relies on v2 of common-package? I'm actually assuming pip will install all dependent packages anyway, so while we might end up with repeated installs of dependant packages, there are certainly some 'common' packages that won't necessarily be dependencies of anything and so will only be installed once in the common folder

            cheers Chris Maunder

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            I've never come across a situation which would need A and B to co-exist in that way, so it's difficult to give a useful answer. But unless you are running A and B at (more or less) the same time in the same shell, do you really need to share between them?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups