Skip to content
  • Search
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

ZMT zurich med tech

  1. Home
  2. Sim4Life
  3. Python API
  4. Installing Additional Python Packages in Sim4Life Environment

Installing Additional Python Packages in Sim4Life Environment

Scheduled Pinned Locked Moved Solved Python API
pythonpip
9 Posts 3 Posters 587 Views
  • 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.
  • A Offline
    A Offline
    andrea_h
    wrote on last edited by andrea_h
    #1

    Hi all,

    I have been working with the Sim4Life Visual Studio Code Extension. While some modules like numpy work perfectly, others give a "ModuleNotFoundError."

    I believe this is because I am running my script in the Sim4Life environment, and certain packages are not included by default.

    My question is: Is there a way to install additional packages within the Sim4Life environment so I can use them in my scripts?

    Any suggestions or guidance would be greatly appreciated! :)

    1 Reply Last reply
    1
    • A andrea_h marked this topic as a question on
    • SylvainS Offline
      SylvainS Offline
      Sylvain
      ZMT
      wrote on last edited by
      #2

      yes, you can install additional packages in the Python environment that Sim4Life is running. Simply type this in a console (using e.g. "cmd.exe"):

      "C:\Program Files\Sim4Life_xyz\Python\python.exe" -m pip install package_name
      

      adjusting for Sim4Life's version number and your package_name.
      You most likely won't even need to restart Sim4Life.

      G 1 Reply Last reply
      1
      • A Offline
        A Offline
        andrea_h
        wrote on last edited by
        #3

        Thanks for your response! It worked perfectly :) (without even restarting Sim4Life)

        1 Reply Last reply
        0
        • SylvainS Sylvain has marked this topic as solved on
        • SylvainS Sylvain

          yes, you can install additional packages in the Python environment that Sim4Life is running. Simply type this in a console (using e.g. "cmd.exe"):

          "C:\Program Files\Sim4Life_xyz\Python\python.exe" -m pip install package_name
          

          adjusting for Sim4Life's version number and your package_name.
          You most likely won't even need to restart Sim4Life.

          G Offline
          G Offline
          gc00
          wrote on last edited by
          #4

          @Sylvain I would like to add new packages too (e.g., dipy), but I don't have such directory in my computer, is it a problem?
          Despite the fact I have not a python.exe, I can run Python script in Sim4Life.
          Thanks in advance!

          SylvainS 1 Reply Last reply
          0
          • G gc00

            @Sylvain I would like to add new packages too (e.g., dipy), but I don't have such directory in my computer, is it a problem?
            Despite the fact I have not a python.exe, I can run Python script in Sim4Life.
            Thanks in advance!

            SylvainS Offline
            SylvainS Offline
            Sylvain
            ZMT
            wrote on last edited by Sylvain
            #5

            @gc00 try typing this in Sim4Life's console (View -> Console), it will give you a clue as to the location of the Python directory:

            import os
            print(os.__file__)
            
            G 2 Replies Last reply
            0
            • SylvainS Sylvain

              @gc00 try typing this in Sim4Life's console (View -> Console), it will give you a clue as to the location of the Python directory:

              import os
              print(os.__file__)
              
              G Offline
              G Offline
              gc00
              wrote on last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • SylvainS Sylvain

                @gc00 try typing this in Sim4Life's console (View -> Console), it will give you a clue as to the location of the Python directory:

                import os
                print(os.__file__)
                
                G Offline
                G Offline
                gc00
                wrote on last edited by
                #7

                @Sylvain it printed: C:\Program Files\Sim4Life_7.2.3.12730\Python\lib\os.py

                1 Reply Last reply
                0
                • SylvainS Offline
                  SylvainS Offline
                  Sylvain
                  ZMT
                  wrote on last edited by
                  #8

                  then it means that you can find python.exe in this directory:
                  C:\Program Files\Sim4Life_7.2.3.12730\Python

                  So you should be able to run:

                  "C:\Program Files\Sim4Life_7.2.3.12730\Python\python.exe" -m pip install package_name
                  

                  from Windows' console (NOT the Console of Sim4Life)

                  G 1 Reply Last reply
                  0
                  • SylvainS Sylvain

                    then it means that you can find python.exe in this directory:
                    C:\Program Files\Sim4Life_7.2.3.12730\Python

                    So you should be able to run:

                    "C:\Program Files\Sim4Life_7.2.3.12730\Python\python.exe" -m pip install package_name
                    

                    from Windows' console (NOT the Console of Sim4Life)

                    G Offline
                    G Offline
                    gc00
                    wrote on last edited by
                    #9

                    @Sylvain Yes thanks finally I succeed!

                    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
                    • Search