diff --git a/CHANGES.md b/CHANGES.md
index b7f6aef7..35aeea84 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,4 +1,9 @@
-### 3.27.3 (2023-02-15 02:00:00 UTC)
+### 3.27.4 (2023-02-15 13:30:00 UTC)
+
+* Fix updating with running virtualenv
+
+
+### 3.27.3 (2023-02-15 02:00:00 UTC)
* Fix reading legacy autoProcessTV.cfg
diff --git a/gui/slick/interfaces/default/config_general.tmpl b/gui/slick/interfaces/default/config_general.tmpl
index 0818e2e6..9f604721 100644
--- a/gui/slick/interfaces/default/config_general.tmpl
+++ b/gui/slick/interfaces/default/config_general.tmpl
@@ -272,7 +272,7 @@
#end for
-
+
diff --git a/lib/sg_helpers.py b/lib/sg_helpers.py
index 67f2c771..b058b38a 100644
--- a/lib/sg_helpers.py
+++ b/lib/sg_helpers.py
@@ -1734,3 +1734,13 @@ def iterate_chunk(lst, n):
"""
for i in moves.range(0, len(lst), n):
yield lst[i:i + n]
+
+
+def is_virtualenv():
+ # type: (...) -> bool
+ """
+ :return: True if virtualenv Python environment is detected
+ """
+ """Get base/real prefix, or `sys.prefix` if there is none."""
+ get_base_prefix_compat = getattr(sys, 'base_prefix', None) or getattr(sys, 'real_prefix', None) or sys.prefix
+ return get_base_prefix_compat != sys.prefix
diff --git a/sickgear/piper.py b/sickgear/piper.py
index 6ac111e9..e904ce01 100644
--- a/sickgear/piper.py
+++ b/sickgear/piper.py
@@ -16,7 +16,7 @@ import os
import re
from json_helper import json_loads
-from sg_helpers import cmdline_runner
+from sg_helpers import cmdline_runner, is_virtualenv
from _23 import filter_list, ordered_dict
from six import iteritems, PY2
@@ -105,7 +105,7 @@ def initial_requirements():
run_pip(['uninstall', '-r', 'recommended-remove.txt'])
raise ValueError
except (BaseException, ImportError):
- run_pip(['install', '-U', '--user', '-r', 'requirements.txt'])
+ run_pip(['install', '-U'] + (['--user'], [])[is_virtualenv()] + ['-r', 'requirements.txt'])
module = 'Cheetah'
try:
locals()[module] = __import__(module)
@@ -327,7 +327,8 @@ def pip_update(loading_msg, updates_todo, data_dir):
# exclude Cheetah3 to prevent `No matching distro found` and fallback to its legacy setup.py installer
output, err, exit_status = run_pip(['install', '-U']
+ ([], ['--only-binary=:all:'])[cur_project_name not in ('Cheetah3', )]
- + ['--user', '-r', piper_path, '--extra-index-url',
+ + (['--user'], [])[is_virtualenv()]
+ + ['-r', piper_path, '--extra-index-url',
'https://gitlab+deploy-token-1599941:UNupqjtDab_zxNzvP2gA@gitlab.com/api/'
'v4/projects/279215/packages/pypi/simple'])
pip_version = None
diff --git a/sickgear/webserve.py b/sickgear/webserve.py
index 13ab4a6d..180dc025 100644
--- a/sickgear/webserve.py
+++ b/sickgear/webserve.py
@@ -41,7 +41,7 @@ import exceptions_helper
import encodingKludge as ek
from json_helper import json_dumps, json_loads
import sg_helpers
-from sg_helpers import remove_file, scantree
+from sg_helpers import remove_file, scantree, is_virtualenv
import sickgear
from . import classes, clients, config, db, helpers, history, image_cache, logger, name_cache, naming, \
@@ -7937,6 +7937,7 @@ class ConfigGeneral(Config):
t.request_host = helpers.xhtml_escape(self.request.host_name, False)
api_keys = '|||'.join([':::'.join(a) for a in sickgear.API_KEYS])
t.api_keys = api_keys and sickgear.API_KEYS or []
+ t.pip_user_arg = ('--user ', '')[is_virtualenv()]
if 'git' == sickgear.update_software_scheduler.action.install_type:
# noinspection PyProtectedMember
sickgear.update_software_scheduler.action.updater._find_installed_version()