Python在虚拟环境中工作时遇到问题

2024-10-04 03:26:49 发布

您现在位置:Python中文网/ 问答频道 /正文

前几天我安装了诗歌,一切都很顺利。我创建了一个项目,并能够使用POYMENT命令在venv内部进行操作。然后,我创建了一个新项目,只是为了尝试一些影响我当前(更重要)项目的东西。从那时起,我不能在任何新项目中使用诗歌venv(诗歌外壳),但当我回到我的主要项目时,它仍然可以完美地工作。对此我很感激,但我想知道发生了什么,以备将来使用。下面是我在一个用诗歌创建的新目录的venv中尝试过的一些事情。任何关于可能出现问题的想法。我甚至卸载和重新安装了它,并不断得到相同的错误。谢谢你抽出时间

The virtual environment found in /home/jesse/.cache/pypoetry/virtualenvs/demo-OhcC5qq9-py3.8 seems to be broken.
Recreating virtualenv demo-OhcC5qq9-py3.8 in /home/jesse/.cache/pypoetry/virtualenvs/demo-OhcC5qq9-py3.8

  FileNotFoundError

  [Errno 2] No such file or directory: '/home/jesse/.cache/pypoetry/virtualenvs/demo-OhcC5qq9-py3.8/bin/python3'

  at ~/.poetry/lib/poetry/_vendor/py3.8/virtualenv/discovery/builtin.py:61 in propose_interpreters
       57│ def propose_interpreters(spec, app_data):
       58│     # 1. if it's a path and exists
       59│     if spec.path is not None:
       60│         try:
    →  61│             os.lstat(spec.path)  # Windows Store Python does not work with os.path.exists, but does for os.lstat
       62│         except OSError:
       63│             if spec.is_abs:
       64│                 raise
       65│         else:
(demo-OhcC5qq9-py3.8) jesse@superuser:~/demo$ poetry add requests

  FileNotFoundError

  [Errno 2] No such file or directory: 'python'

  at /usr/lib/python3.8/subprocess.py:1702 in _execute_child
      1698│                     else:
      1699│                         err_filename = orig_executable
      1700│                     if errno_num != 0:
      1701│                         err_msg = os.strerror(errno_num)
    → 1702│                     raise child_exception_type(errno_num, err_msg, err_filename)
      1703│                 raise child_exception_type(err_msg)
      1704│
      1705│
      1706│         def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,
'''

Tags: path项目incachehomeifvenvos