- Я создал новый проект Python с pixi venv < /strong>.
У меня есть изолированный Venv, включая Python.
Я установил Pandas < /code> и т. Д.
Я не установил plotly < /code> и т. Д.
в глобальной среде Python установлено значение < /code>. < /p>
< /li>
< /ul>
проблема < /h3>
Теперь я открываю проект в коде VS. ПЛОНА .
он не покажет никакой ошибки.
Если я нажму на него, он переходит на глобальные сайты Python Env.
то же самое происходит. -
- Я хочу, чтобы код VS действительно изолировал Вен.
остановить его от импорта из Global Python Site-Packages.
Просто покажите ошибку, если это происходит в моем коде. PythonnuseRsite = 1 < /code>,
не будет работать для VS Code Ide < /li>
только работает в терминале (этого недостаточно) < /li>
< /ul>
< /li>
< /li>
< /ul>
< /li>
include-system-site-packages = false не существует для Pixi.
compare
- Если я создаю проект с .venv , нет такой проблемы , он действительно изолирован, и VS -код. Env Site-Packages или нет).
- Если я создаю проект с .conda , у некоторых проектов нет такой проблемы, (базовая env), но другие, кажется, имеют одинаковую проблему
- Если я создаю проект с .pixi , есть проблема
import os
# Print the executable python thinks it's running
print("--- Python Executable ---")
print(sys.executable)
print("-" * 25)
# Print all the paths python will search for modules
print("\n--- Module Search Paths (sys.path) ---")
for path in sys.path:
print(path)
print("-" * 25)
# Check if the PYTHONPATH variable is set
print("\n--- PYTHONPATH Environment Variable ---")
py_path = os.environ.get('PYTHONPATH')
if py_path:
print(py_path.replace(':', '\n')) # Use ';' for Windows if needed
else:
print("PYTHONPATH is not set.")
print("-" * 25)
# Try the import and see where it comes from
try:
import pandas
print("\n--- 'pandas' was found here: ---")
print(pandas.__file__)
except ImportError:
print("\n--- 'pandas' could not be imported. ---")
try:
import plotly
print("\n--- 'plotly' was found here: ---")
print(plotly.__file__)
except ImportError:
print("\n--- 'plotly' could not be imported. ---")
try:
import torch
print("\n--- 'torch' was found here: ---")
print(torch.__file__)
except ImportError:
print("\n--- 'torch' could not be imported. ---")
< /code>
output: < /p>
D:\usp\uhpsj\study\build_llm_wsp\build_llm>D:/usp/uhpsj/study/build_llm_wsp/build_llm/.pixi/envs/default/python.exe d:/usp/uhpsj/study/build_llm_wsp/build_llm/src/build_llm_demo/_demo/d2.py
--- Python Executable ---
D:\usp\uhpsj\study\build_llm_wsp\build_llm\.pixi\envs\default\python.exe
-------------------------
--- Module Search Paths (sys.path) ---
d:\usp\uhpsj\study\build_llm_wsp\build_llm\src\build_llm_demo\_demo
D:\usp\uhpsj\study\build_llm_wsp\build_llm\.pixi\envs\default\python311.zip
D:\usp\uhpsj\study\build_llm_wsp\build_llm\.pixi\envs\default\DLLs
D:\usp\uhpsj\study\build_llm_wsp\build_llm\.pixi\envs\default\Lib
D:\usp\uhpsj\study\build_llm_wsp\build_llm\.pixi\envs\default
C:\Users\nshln\AppData\Roaming\Python\Python311\site-packages
D:\usp\uhpsj\study\build_llm_wsp\build_llm\.pixi\envs\default\Lib\site-packages
D:\usp\uhpsj\study\build_llm_wsp\build_llm\.pixi\envs\default\Lib\site-packages\win32
D:\usp\uhpsj\study\build_llm_wsp\build_llm\.pixi\envs\default\Lib\site-packages\win32\lib
D:\usp\uhpsj\study\build_llm_wsp\build_llm\.pixi\envs\default\Lib\site-packages\Pythonwin
-------------------------
--- PYTHONPATH Environment Variable ---
PYTHONPATH is not set.
-------------------------
--- 'pandas' was found here: ---
C:\Users\nshln\AppData\Roaming\Python\Python311\site-packages\pandas\__init__.py
--- 'plotly' was found here: ---
C:\Users\nshln\AppData\Roaming\Python\Python311\site-packages\plotly\__init__.py
--- 'torch' was found here: ---
C:\Users\nshln\AppData\Roaming\Python\Python311\site-packages\torch\__init__.py
< /code>
pixi.toml Пакеты
[workspace]
authors = ["norlz "]
channels = ["conda-forge"]
name = "build-llm-demo"
platforms = ["win-64"]
version = "0.1.0"
[tasks]
[system-requirements]
cuda = "12.0"
[dependencies]
python = "3.11.*"
pandas = "=2.9.1,=0.12.0,=1.1.402,=8.4.1,=0.115.13, =0.34.3, =23.0.0,
Подробнее здесь: https://stackoverflow.com/questions/796 ... when-using