Have to keep reinstalling python modules (Eclipse Che)?

点点圈 提交于 2019-12-11 05:15:26

问题


For my Eclipse Che project, I have to reinstall my python modules every time I load the workspace (blegh). Is there a way to install the modules my team needs to a global folder so they don't have to even install the python modules every time they want to load the project? Thank you!


回答1:


Alternatively you can build your workspace from a stack based on a Dockerfile recipe:

  1. First, write down all your installation commands that you execute in Eclipse Che terminal when customising your workspace

  2. Next, create a new Dockerfile based on the one you are currently using

    2.1. find the Dockerfile your current workspace is based on from
    recipes (e.g. for default Python stack it would be this one)

    2.2. modify that file by adding your installation commands from previous step before the last line (EXPOSE 8080) like this:
    RUN sudo -H pip install flask && sudo -H pip install pandas etc...

  3. In Eclipse Che create a new custom stack based on your Dockerfile

    3.1. Click Stacks on the left (below Workspaces) and click “Add Stack”

    3.2. In “Build stack from recipe” dialog select Dockerfile tab and paste there the content of your modified Dockerfile

    3.3. Click OK => new page opens where you can further customise your stack

    3.4. Edit the name and description, then click NEW-MACHINE to set the memory size as you like then click SAVE (right upper corner)

    3.5. Click again NEW-MACHINE to add some essential Agents: “Workspace API”, “Terminal”, “Exec” and other language servers that you need (e.g. “Python language server”)

    3.6 You can customise your stack further by adding environment vars or servers etc…

  4. Hit SAVE and then TEST to test your stack

  5. On the new dialog that opens you can specify some default project to be added than click “Test Workspace”

  6. If workspace will build successfully your will see below message in green “Your workspace is ready to be used” and the stack will be added to the Stacks. Also your new-machine and Terminal will be opened below

  7. Now close “Testing Stack”, go to Workspaces or Dashboard and create a new Workspace

  8. Your newly created stack should be visible there under stacks so you can select it now and build your workspace based on that




回答2:


You can also declare a volume for your workspace where python modules will be persisted.

From the Che documentation:

You can add volumes either by using the User Dashboard or by updating the machine configuration. The following is an example of the configuration file:

"volumes": {
  "myvolume": {
    "path": "/absolute/path/in/workspace"
  }
}



回答3:


If I understand you question correctly, the best approach would be to build new docker image (based on the one you are using now) with the modules pre-installed and use that image for workspace instead of the default one.



来源:https://stackoverflow.com/questions/54793121/have-to-keep-reinstalling-python-modules-eclipse-che

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!