diff --git a/CHANGES.md b/CHANGES.md
index f25b3879..f453fc6b 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -4,6 +4,11 @@
* Change requirements for pure py3
+### 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 e7ad08c1..4601b512 100644
--- a/lib/sg_helpers.py
+++ b/lib/sg_helpers.py
@@ -1733,3 +1733,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 99ee0ee3..65217b8d 100644
--- a/sickgear/piper.py
+++ b/sickgear/piper.py
@@ -8,7 +8,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
@@ -97,7 +97,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)
@@ -319,7 +319,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 cfbafc7a..b26ec8ff 100644
--- a/sickgear/webserve.py
+++ b/sickgear/webserve.py
@@ -39,7 +39,7 @@ from exceptions_helper import ex, MultipleShowObjectsException
import exceptions_helper
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, \
@@ -7934,6 +7934,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()