Problem description:
NixOS Errors on Package Support for Python 311 langchain. Use Case, Document Vector without using OpenAI APIs, pure python. No working example of this could be found using search on replit, they all use APIs.
Expected behavior: System Ready
Actual behavior:
~/langchainsupport$
Detected change in environment, reloading shell...
nix error: building nix env: exit status 1
Output has been trimmed to the last 20 lines
instantiated 'YAML-Tiny-1.73.tar.gz' -> '/nix/store/0j04z434xl9829mx8rvaxnk9v3kvibw5-YAML-Tiny-1.73.tar.gz.drv'
instantiated 'perl5.36.0-YAML-Tiny-1.73' -> '/nix/store/cr1gv08fii6jmm6yysk4w5pa50g53q53-perl5.36.0-YAML-Tiny-1.73.drv'
instantiated 'po4a-0.62.tar.gz' -> '/nix/store/ys8blq95nqqw90v9189mwpz1kmxl72j1-po4a-0.62.tar.gz.drv'
instantiated 'perl5.36.0-po4a-0.62' -> '/nix/store/c0d3xl6fzhyd2k8ldahqm2vkk56zw3hn-perl5.36.0-po4a-0.62.drv'
instantiated 'util-linux-2.38.1.tar.xz' -> '/nix/store/c8y7381wbz9gyg737knyf2f9pi354qwq-util-linux-2.38.1.tar.xz.drv'
instantiated 'util-linux-2.38.1' -> '/nix/store/27nxqn5jj7hw7142xipqb5ckfgl6m6q3-util-linux-2.38.1.drv'
evaluating file '/nix/store/4va5hjb3sdk8pnpn3dsnkdg65fw28jgv-nixpkgs-23.05-src/pkgs/development/python-modules/sympy/default.nix'
evaluating file '/nix/store/4va5hjb3sdk8pnpn3dsnkdg65fw28jgv-nixpkgs-23.05-src/pkgs/development/python-modules/mpmath/default.nix'
instantiated 'CVE-2021-29063.patch' -> '/nix/store/1p9ljzvsw6h5nsj0q9g85rsks8vdf0n4-CVE-2021-29063.patch.drv'
instantiated 'mpmath-1.2.1.tar.gz' -> '/nix/store/fphss2hbg77rrxszhi9mb4lg2x29zf3d-mpmath-1.2.1.tar.gz.drv'
instantiated 'python3.11-mpmath-1.2.1' -> '/nix/store/kz933nw77a7552873hl1fyd051csaybd-python3.11-mpmath-1.2.1.drv'
instantiated 'sympy-1.11.1.tar.gz' -> '/nix/store/1zymkbjvvqac5d0nyyawhwb5armxy5g2-sympy-1.11.1.tar.gz.drv'
instantiated 'python3.11-sympy-1.11.1' -> '/nix/store/ypswa3v5x0pkmvv9i5wvjdk8rq3pdvl5-python3.11-sympy-1.11.1.drv'
evaluating file '/nix/store/4va5hjb3sdk8pnpn3dsnkdg65fw28jgv-nixpkgs-23.05-src/pkgs/development/python-modules/future/default.nix'
instantiated 'future-0.18.3.tar.gz' -> '/nix/store/sba3xg23yn9ah21wj7ag5v1ld7j89dab-future-0.18.3.tar.gz.drv'
instantiated 'python3.11-future-0.18.3' -> '/nix/store/8xsa63fmm6macszdfrbbwk9qbcwkdzrv-python3.11-future-0.18.3.drv'
evaluating file '/nix/store/4va5hjb3sdk8pnpn3dsnkdg65fw28jgv-nixpkgs-23.05-src/pkgs/development/python-modules/tensorboard/default.nix'
error: tensorboard-2.11.0 not supported for interpreter python3.11
(use '--show-trace' to show detailed location information)
This was a bug in nixpkgs that has been fixed, but the Nix channels are outdated because replit stores a cached copy of nixpkgs which it has to update manually. As a workaround, install langchain through the “Packages” tool.
Alternatively, you could try and add this to replit.nix:
when you’re doing this sort of workaround, if there’s an internal import error with a package, add that package to the python311.withPackages callback return value array, as I’ve done with numpy etc. (so it uses the correct native module for 3.11).
to get langchain to work with python 3.11 on what’s currently the Beta Python template while we wait for replit’s Nix index to update, all you need to do is edit your replit.nix file like this
@UMARismyname open question: why 3.10? Doesn’t seem to be be needed. Is it?
Tested this (above), it still isn’t searching the venv for the alternate packages installed in the virtual environment. I can’t get venv to function correctly yet, haven’t lost hope.
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 23.0.1
Not uninstalling pip at /nix/store/yi6scf22zanz3c3jcq60dh94i12fn1d1-python3.11-pip-23.0.1/lib/python3.11/site-packages, outside environment /home/runner/langchainsupport3/virt
Can't uninstall 'pip'. No files were found to uninstall.
Successfully installed pip-22.3.1
[notice] A new release of pip is available: 23.0.1 -> 23.2.1
[notice] To update, run: pip install --upgrade pip
(virt) ~/langchainsupport3$ pip -V
pip 23.0.1 from /nix/store/yi6scf22zanz3c3jcq60dh94i12fn1d1-python3.11-pip-23.0.1/lib/python3.11/site-packages/pip (python 3.11)
Need to modify $PYTHONPATH being used in the venv to use modified path for pip and langchain
#pip config list to locate:
PIP_CONFIG_FILE=/nix/store/crvjb24kkwvcnrhjyk91p9w4bbh9ahf6-pip.conf
#cp above to .config directory, update it to be venv compliant
export PIP_CONFIG_FILE=/home/runner/langchainsupport3/.config/pip.conf
Both venv and non-venv packages are working and pip shows the updated version in this test.
Looks close…only wish I could have figured this out earlier … but challenges learning is great! @UMARismyname Thanks for your great patience and support!
@UMARismyname Yoda, update for all and you observers…Everything looks normal now, stuff is set in venv, untouched outside of it, then restored again once deactivated.
I think we have this one solved.
Outside of venv:
~/langchainsupport3$ pip -V
pip 23.0.1 from /nix/store/yi6scf22zanz3c3jcq60dh94i12fn1d1-python3.11-pip-23.0.1/lib/python3.11/site-packages/pip (python 3.11)
~/langchainsupport3$
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly
deactivate () {
# reset old environment variables
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
PATH="${_OLD_VIRTUAL_PATH:-}"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
fi
#Added - For Replit / Nix OS Issues
if [ -n "${_OLD_PIP_CONFIG_FILE:-}" ] ; then
PIP_CONFIG_FILE="${_OLD_PIP_CONFIG_FILE:-}"
export PIP_CONFIG_FILE
unset _OLD_PIP_CONFIG_FILE
fi
#Added - For Replit / Nix OS Issues
if [ -n "${_OLD_PYTHONPATH:-}" ] ; then
PYTHONPATH="${_OLD_PYTHONPATH:-}"
export PYTHONPATH
unset _OLD_PYTHONPATH
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r 2> /dev/null
fi
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
PS1="${_OLD_VIRTUAL_PS1:-}"
export PS1
unset _OLD_VIRTUAL_PS1
fi
unset VIRTUAL_ENV
unset VIRTUAL_ENV_PROMPT
if [ ! "${1:-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}
# unset irrelevant variables
deactivate nondestructive
VIRTUAL_ENV="/home/runner/langchainsupport3/virt"
export VIRTUAL_ENV
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH
#Added - For Replit / Nix OS Issues
_OLD_PYTHONPATH="$PYTHONPATH"
PYTHONPATH="$VIRTUAL_ENV/lib/python3.11/site-packages/"
export PYTHONPATH
#Added - For Replit / Nix OS Issues
_OLD_PIP_CONFIG_FILE="$PIP_CONFIG_FILE"
PIP_CONFIG_FILE="/home/runner/langchainsupport3/.config/pip.conf"
export PIP_CONFIG_FILE
# unset PYTHONHOME if set
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
# could use `if (set -u; : $PYTHONHOME) ;` in bash
if [ -n "${PYTHONHOME:-}" ] ; then
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
unset PYTHONHOME
fi
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
_OLD_VIRTUAL_PS1="${PS1:-}"
PS1="(virt) ${PS1:-}"
export PS1
VIRTUAL_ENV_PROMPT="(virt) "
export VIRTUAL_ENV_PROMPT
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r 2> /dev/null
fi