我想运行一个使用python2.7版本的应用程序,但默认没有安装python2.7。当我尝试使用时:
$ virtualenv -p python2 flaskold
它返回:
RuntimeError: failed to find interpreter for Builtin discover of python_spec='python2'
如何在没有 python 2.7 支持的 Ubuntu 20.04 上创建 python2.7 虚拟环境?
我想运行一个使用python2.7版本的应用程序,但默认没有安装python2.7。当我尝试使用时:
$ virtualenv -p python2 flaskold
它返回:
RuntimeError: failed to find interpreter for Builtin discover of python_spec='python2'
如何在没有 python 2.7 支持的 Ubuntu 20.04 上创建 python2.7 虚拟环境?
与标题一样,如何以 sudo 权限运行安装在 conda 环境中的程序?
该线程(sudo: conda: command not found)提到 conda 命令不能被授予超级用户权限。但是我需要这个特定的程序被授予完全的写入和编辑权限。我尝试更改相关文件夹/程序的权限,但每次都会自动重置为“仅访问”权限。
有什么想法可以规避这个问题吗?
我正在开发一个虚拟环境:sk
,我是这样制作的:
$ mkvirtualenv sk -p python3
我workon sk
用来激活这个环境并在其中工作。当我尝试在其中运行该perf
实用程序的某些功能时,它会请求许可;它建议我使用sudo
. 这样做时,环境的本质就会丢失,因为它没有检测到我在其中安装的任何包(例如pandas
)。
我已经在这个网站上浏览了与这里类似的文章,它建议使用命令
sudo ./AwesomeProject/bin/python <script>
virtualenv 在哪里./AwesomeProject
。我试了一下,发现我的虚拟环境中的 Python 实例是./.virtualenvs/sk/bin/python3
. 我将实例运行为:
$./.virtualenvs/sk/bin/python3 main.py
我明白了bash: .virtualenvs/sk/bin/python3: No such file or directory
(main.py
是我打算运行的python脚本)
为什么我使用 sudo 会遇到这个错误,我应该如何克服这个错误?
尝试启动虚拟环境时,我得到:
~$ python3 -m venv homeassistant
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
apt-get install python3-venv
You may need to use sudo with that command. After installing the python3-venv
package, recreate your virtual environment.
Failing command: ['/home/gal/homeassistant/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']
但是当我尝试安装 python3-venv 我得到:
~$ sudo apt-get install python3-venv
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-venv is already the newest version (3.6.7-1~18.04).
0 upgraded, 0 newly installed, 0 to remove and 38 not upgraded.
我应该安装几个 python 版本,但我将它们作为替代方案删除:
~$ sudo update-alternatives --config python3
There is only one alternative in link group python3 (providing /usr/bin/python3): /~$ sudo update-alternatives --config python3
There is only one alternative in link group python3 (providing /usr/bin/python3): /usr/bin/python3.7
Nothing to configure.usr/bin/python3.7
Nothing to configure.
Python 版本是 3.7.5:
~$ python3 --version
Python 3.7.5
操作系统版本为:
~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
我认为问题在于'python3-venv 已经是最新版本(3.6.7-1~18.04)。而我使用的版本是 3.7 而不是 3.6。但我不知道如何进行。
感谢您的任何建议。
我正在使用 Ubuntu 伴侣:
操作系统:Ubuntu 16.04.6 LTS
内核:Linux 3.4.39-BPI-M3-内核
架构:手臂
我已经安装了 Python 2.7 & 3.5.2 以及 3.7.7
Wnen 我正在尝试安装 virtualenv 错误返回:
pi@bpi-iot-ros-ai:/usr/bin$ pip3 install virtualenv Defaulting to user
installation because normal site-packages is not writeable ERROR:
Exception: Traceback (most recent call last): File
"/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py",
line 188, in _main
status = self.run(options, args) File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py",
line 185, in wrapper
return func(self, options, args) File "/usr/local/lib/python3.7/site-packages/pip/_internal/commands/install.py",
line 278, in run
session = self.get_default_session(options) File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py",
line 83, in get_default_session
self._session = self.enter_context(self._build_session(options)) File
"/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py",
line 100, in _build_session
index_urls=self._get_index_urls(options), File "/usr/local/lib/python3.7/site-packages/pip/_internal/network/session.py",
line 249, in __init__
self.headers["User-Agent"] = user_agent() File "/usr/local/lib/python3.7/site-packages/pip/_internal/network/session.py",
line 132, in user_agent
zip(["name", "version", "id"], distro.linux_distribution()), File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py",
line 125, in linux_distribution
return _distro.linux_distribution(full_distribution_name) File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
681, in linux_distribution
self.version(), File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
741, in version
self.lsb_release_attr('release'), File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
903, in lsb_release_attr
return self._lsb_release_info.get(attribute, '') File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
556, in __get__
ret = obj.__dict__[self._fname] = self._f(obj) File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
1014, in _lsb_release_info
stdout = subprocess.check_output(cmd, stderr=devnull) File "/usr/local/lib/python3.7/subprocess.py", line 411, in check_output
**kwargs).stdout File "/usr/local/lib/python3.7/subprocess.py", line 512, in run
output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
Traceback (most recent call last): File "/usr/local/bin/pip3", line
10, in <module>
sys.exit(main()) File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/main.py",
line 75, in main
return command.main(cmd_args) File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py",
line 114, in main
return self._main(args) File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py",
line 226, in _main
self.handle_pip_version_check(options) File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py",
line 155, in handle_pip_version_check
timeout=min(5, options.timeout) File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py",
line 100, in _build_session
index_urls=self._get_index_urls(options), File "/usr/local/lib/python3.7/site-packages/pip/_internal/network/session.py",
line 249, in __init__
self.headers["User-Agent"] = user_agent() File "/usr/local/lib/python3.7/site-packages/pip/_internal/network/session.py",
line 132, in user_agent
zip(["name", "version", "id"], distro.linux_distribution()), File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py",
line 125, in linux_distribution
return _distro.linux_distribution(full_distribution_name) File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
681, in linux_distribution
self.version(), File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
741, in version
self.lsb_release_attr('release'), File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
903, in lsb_release_attr
return self._lsb_release_info.get(attribute, '') File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
556, in __get__
ret = obj.__dict__[self._fname] = self._f(obj) File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line
1014, in _lsb_release_info
stdout = subprocess.check_output(cmd, stderr=devnull) File "/usr/local/lib/python3.7/subprocess.py", line 411, in check_output
**kwargs).stdout File "/usr/local/lib/python3.7/subprocess.py", line 512, in run
output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
pi@bpi-iot-ros-ai:/usr/bin$
如果我使用 --user 标志:
pi@bpi-iot-ros-ai:/usr/bin$ pip3 install virtualenv --user
ERROR: Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 188, in _main
status = self.run(options, args)
File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 185, in wrapper
return func(self, options, args)
File "/usr/local/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 278, in run
session = self.get_default_session(options)
File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 83, in get_default_session
self._session = self.enter_context(self._build_session(options))
File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 100, in _build_session
index_urls=self._get_index_urls(options),
File "/usr/local/lib/python3.7/site-packages/pip/_internal/network/session.py", line 249, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.7/site-packages/pip/_internal/network/session.py", line 132, in user_agent
zip(["name", "version", "id"], distro.linux_distribution()),
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 125, in linux_distribution
return _distro.linux_distribution(full_distribution_name)
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 681, in linux_distribution
self.version(),
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 741, in version
self.lsb_release_attr('release'),
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 903, in lsb_release_attr
return self._lsb_release_info.get(attribute, '')
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 556, in __get__
ret = obj.__dict__[self._fname] = self._f(obj)
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 1014, in _lsb_release_info
stdout = subprocess.check_output(cmd, stderr=devnull)
File "/usr/local/lib/python3.7/subprocess.py", line 411, in check_output
**kwargs).stdout
File "/usr/local/lib/python3.7/subprocess.py", line 512, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 10, in <module>
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/main.py", line 75, in main
return command.main(cmd_args)
File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 114, in main
return self._main(args)
File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 226, in _main
self.handle_pip_version_check(options)
File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 155, in handle_pip_version_check
timeout=min(5, options.timeout)
File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 100, in _build_session
index_urls=self._get_index_urls(options),
File "/usr/local/lib/python3.7/site-packages/pip/_internal/network/session.py", line 249, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.7/site-packages/pip/_internal/network/session.py", line 132, in user_agent
zip(["name", "version", "id"], distro.linux_distribution()),
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 125, in linux_distribution
return _distro.linux_distribution(full_distribution_name)
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 681, in linux_distribution
self.version(),
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 741, in version
self.lsb_release_attr('release'),
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 903, in lsb_release_attr
return self._lsb_release_info.get(attribute, '')
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 556, in __get__
ret = obj.__dict__[self._fname] = self._f(obj)
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/distro.py", line 1014, in _lsb_release_info
stdout = subprocess.check_output(cmd, stderr=devnull)
File "/usr/local/lib/python3.7/subprocess.py", line 411, in check_output
**kwargs).stdout
File "/usr/local/lib/python3.7/subprocess.py", line 512, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
pi@bpi-iot-ros-ai:/usr/bin$
如何处理?
我最近从 19.10 升级到 20.04。现在我面临问题,因为我需要使用 Python 3.7 的虚拟环境并且似乎无法安装软件包: - Python3.7-venv - Python 3.7-dev
20.04 似乎不支持这些。
有什么方法可以为 20.04 安装它们吗?如果我在升级过程中不进行自动删除,它们还能工作吗?
我希望避免重新安装 19.10。
我对 Linux 很陌生,所以我可能更多地以 Windows 的方式思考。
我想用 Python 开发一些东西,尤其是 Django 和 Discord Bot。我有一个文件夹PythonEnvironment
,我在其中设置了一个名为pyvenv
. 现在我想安装“discord.py”并问自己:我应该为discord.py
它自己的 Venv(例如discordvenv
)和 Django 设置它自己的 Venv(例如djangovenv
),还是只在一个 Venv 中安装所有东西?
当我安装了我需要的所有东西时,我可以像在 Windows 中一样开始在 PyCharm 中编程,还是我必须做更多的事情,例如告诉 Pycharm 在特定的 Venv 中工作?
我知道virtualenv
andvirtualenvwrapper
代表.py
. python
当我跑virtualenv
进来PyCharm IDE
时:
Usage: virtualenv.py
我最近才遇到这个并尝试搜索它,但我找不到它。virtualenv.py
与仅 tovirtualenv
和相比,它到底是什么,有什么不同virtualwrapper
吗?这两个软件我都没有pip3
安装。
我是 Ubuntu 和 Python virtualenv 的新手。由于我意识到 virtualenv 的重要性,所以我想在我运行 python(从安装包)时默认使用它,这样我就不需要source bin/activate
每次都运行。