简体   繁体   English

如何在虚拟环境中使用 Python 解释器

[英]How to use a Python interpreter in a virtual environment

In Linux Mint distro I have installed pyenv and pyenv-virtualenv so I can activate and deactivate an environment with a given Python version.在 Linux Mint 发行版中,我安装了pyenvpyenv-virtualenv ,因此我可以激活和停用具有给定 Python 版本的环境。

I would like to use bpython or ipython interpreters with an environment but I only can install them with sudo install bpython and not with pip into the environment.我想在环境中使用bpythonipython解释器,但我只能使用sudo install bpython安装它们,而不能使用pip安装到环境中。

For example, if I try to install bpython into environment named gdr with Python 3.8.10 :例如,如果我尝试使用 Python 3.8.10 将bpython安装到名为gdr的环境中:

(gdr) lab@GdRlab:~/Documents/prPy1$ pip install bpython
Collecting bpython
  Using cached bpython-0.22.1-py3-none-any.whl (187 kB)
Collecting pygments
  Using cached Pygments-2.12.0-py3-none-any.whl (1.1 MB)
Collecting cwcwidth
  Using cached cwcwidth-0.1.6-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (52 kB)
Collecting pyxdg
  Using cached pyxdg-0.28-py2.py3-none-any.whl (49 kB)
Collecting requests
  Using cached requests-2.28.1-py3-none-any.whl (62 kB)
Collecting typing-extensions
  Downloading typing_extensions-4.3.0-py3-none-any.whl (25 kB)
Collecting curtsies>=0.3.5
  Using cached curtsies-0.3.10.tar.gz (53 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [67 lines of output]
      running dist_info
      creating /tmp/pip-modern-metadata-r6sz4vv0/curtsies.egg-info
      writing /tmp/pip-modern-metadata-r6sz4vv0/curtsies.egg-info/PKG-INFO
   ......

The above output does not give much information on how to solve it.上面的输出没有提供太多关于如何解决它的信息。

I have always used miniconda (or anaconda), on any operating system.我一直在任何操作系统上使用 miniconda(或 anaconda)。 It works very well as an all-in-one solution for managing Python interpreters, libraries, pip installations, and generally everything related to the virtual environment.它非常适合作为管理 Python 解释器、库、pip 安装以及通常与虚拟环境相关的所有内容的一体化解决方案。 There are no more operating system-dependent installations.不再有依赖于操作系统的安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在我的虚拟环境中使用Python 3(3.5)作为默认解释器? - How to use Python 3 (3.5) as the default interpreter in my virtual environment? Python 解释器未与 PyCharm 虚拟环境链接 - Python interpreter not linking with PyCharm virtual environment 如何在另一台计算机上使用python虚拟环境 - How to use python virtual environment in another computer 如何在虚拟环境 (Ubuntu 18.04LTS) 中更改 Python 解释器? - How can I change the Python interpreter in virtual environment (Ubuntu 18.04LTS)? 如何从 Visual Studio 代码中的现有虚拟环境中设置 Python 解释器 - How to set a Python Interpreter from inside a existing virtual environment in Visual Studio code 选择虚拟环境 Python 解释器的 Visual Studio Code 问题 - Visual Studio Code issue selecting Virtual Environment Python interpreter 在虚拟环境中使用Python 2.7.10 - Use Python 2.7.10 in Virtual Environment 如何在 Anaconda 环境中更改 Python 解释器路径? - How to change Python interpreter path in Anaconda environment? 如何为Python解释器转到/上创建运行时环境? - how to make a runtime environment for Go to/on the Python Interpreter? 如何在 Linux 上的 Python 虚拟环境中安装和使用 Jupyter 实验室? - How to install and use Jupyter lab in a Python virtual environment on Linux?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM