| 157 | |
| 158 | @classmethod |
| 159 | def from_dict(cls, data: Dict) -> Optional["PythonEnvironment"]: |
| 160 | if not isinstance(data, dict): |
| 161 | return None |
| 162 | try: |
| 163 | return cls( |
| 164 | data["bin_path"], |
| 165 | data["version"], |
| 166 | data["type"], |
| 167 | conda_path=data.get("conda_path"), |
| 168 | venv_name=data.get("venv_name"), |
| 169 | activate_sh=data.get("activate_sh"), |
| 170 | system_path=data.get("system_path"), |
| 171 | ps=data.get("ps"), |
| 172 | site_packages=data.get("site_packages"), |
| 173 | ) |
| 174 | except Exception as e: |
| 175 | # print("PythonEnvironment.from_dict error: {}".format(str(e))) |
| 176 | return None |
| 177 | |
| 178 | def create_venv(self, env_path: str, ps: str = "") -> Optional[str]: |
| 179 | if self.env_type != "system": |