Skip to content

Commit

Permalink
fix python home discovery (#424)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Q authored Oct 9, 2024
1 parent 2d8086d commit 5494e49
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions taskweaver/ces/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from dataclasses import dataclass, field
from typing import Any, Dict, List, Literal, Optional, Union

from jupyter_client import BlockingKernelClient
from jupyter_client.blocking.client import BlockingKernelClient
from jupyter_client.kernelspec import KernelSpec, KernelSpecManager
from jupyter_client.manager import KernelManager
from jupyter_client.multikernelmanager import MultiKernelManager
Expand Down Expand Up @@ -187,13 +187,14 @@ def start_session(
os.makedirs(cwd, exist_ok=True)

if self.mode == EnvMode.Local:
# set python home from current python environment
python_home = os.path.sep.join(sys.executable.split(os.path.sep)[:-2])
import site

python_path = os.pathsep.join(
[
# package base directory
os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..")),
os.path.join(python_home, "Lib", "site-packages"),
]
+ site.getsitepackages()
+ sys.path,
)

Expand All @@ -212,7 +213,6 @@ def start_session(
"CONNECTION_FILE": self._get_connection_file(session_id, new_kernel_id),
"PATH": os.environ["PATH"],
"PYTHONPATH": python_path,
"PYTHONHOME": python_home,
},
)
session.kernel_id = self.multi_kernel_manager.start_kernel(
Expand Down

0 comments on commit 5494e49

Please sign in to comment.