I try to add the environment but it show the error

I try to add something in replit.nix, but when I load, it show the error

Detected change in environment, reloading shell...
nix error: building nix env: exit status 1
Output has been trimmed to the last 20 lines
copied source '/nix/store/4va5hjb3sdk8pnpn3dsnkdg65fw28jgv-nixpkgs-23.05-src/pkgs/development/libraries/glibc/nix-nss-open-files.patch' -> '/nix/store/001gp43bjqzx60cg345n2slzg7131za8-nix-nss-open-files.patch'
copied source '/nix/store/4va5hjb3sdk8pnpn3dsnkdg65fw28jgv-nixpkgs-23.05-src/pkgs/development/libraries/glibc/0001-Revert-Remove-all-usage-of-BASH-or-BASH-in-installed.patch' -> '/nix/store/k06glk8f3dxj3k0m9b9y7ph2nbnd1ns0-0001-Revert-Remove-all-usage-of-BASH-or-BASH-in-installed.patch'
copied source '/nix/store/4va5hjb3sdk8pnpn3dsnkdg65fw28jgv-nixpkgs-23.05-src/pkgs/development/libraries/glibc/reenable_DT_HASH.patch' -> '/nix/store/rwnpifhbiky8wmzsfyzah2qpah1z1mzk-reenable_DT_HASH.patch'
evaluating file '/nix/store/4va5hjb3sdk8pnpn3dsnkdg65fw28jgv-nixpkgs-23.05-src/pkgs/development/libraries/libidn2/default.nix'
evaluating file '/nix/store/4va5hjb3sdk8pnpn3dsnkdg65fw28jgv-nixpkgs-23.05-src/pkgs/development/libraries/libunistring/default.nix'
instantiated 'libunistring-1.1.tar.gz' -> '/nix/store/x026yqw2ch0lhcyd548qra2i6gxi2whp-libunistring-1.1.tar.gz.drv'
instantiated 'libunistring-1.1' -> '/nix/store/xvn3anp019d0mcx0hagacyfc0cslh5ih-libunistring-1.1.drv'
instantiated 'libidn2-2.3.4.tar.gz' -> '/nix/store/21xd2nc05x1zyb6q071q0iddsi8075m9-libidn2-2.3.4.tar.gz.drv'
instantiated 'libidn2-2.3.4' -> '/nix/store/x6pncslc93zbdfs4mnga7clbcfadlm0m-libidn2-2.3.4.drv'
instantiated 'glibc-2.37.tar.xz' -> '/nix/store/h635jjqzf1g34hbb87lwki2z56zmvnwb-glibc-2.37.tar.xz.drv'
instantiated 'glibc-2.37-8' -> '/nix/store/018d2v7fy5b3h188cq2ppridpq6hhz7c-glibc-2.37-8.drv'
evaluating file '/nix/store/4va5hjb3sdk8pnpn3dsnkdg65fw28jgv-nixpkgs-23.05-src/pkgs/tools/misc/coreutils/default.nix'
evaluating file '/nix/store/4va5hjb3sdk8pnpn3dsnkdg65fw28jgv-nixpkgs-23.05-src/pkgs/development/libraries/acl/default.nix'
evaluating file '/nix/store/4va5hjb3sdk8pnpn3dsnkdg65fw28jgv-nixpkgs-23.05-src/pkgs/tools/text/gnugrep/default.nix'
evaluating file '/nix/store/4va5hjb3sdk8pnpn3dsnkdg65fw28jgv-nixpkgs-23.05-src/pkgs/tools/text/gawk/default.nix'
evaluating file '/nix/store/4va5hjb3sdk8pnpn3dsnkdg65fw28jgv-nixpkgs-23.05-src/pkgs/build-support/mkshell/default.nix'
evaluating file '/home/runner/BadRadiantGigahertz/replit.nix'
error: attribute 'prybar-python311' missing, at /home/runner/BadRadiantGigahertz/replit.nix:22:28
(use '--show-trace' to show detailed location information)

Here’s the code of replit.nix

{ pkgs }: {
  deps = [
    pkgs.python311
    pkgs.gnome.gedit
    pkgs.xterm
    pkgs.python311.pkgs.pip
    pkgs.python311.pkgs.virtualenv
    pkgs.replitPackages.prybar-python311
    pkgs.replitPackages.stderred    
  ];
  env = {
    PYTHON_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
      pkgs.stdenv.cc.cc.lib
      pkgs.zlib
      pkgs.glib
      pkgs.xorg.libX11
    ];
    PYTHONHOME = "${pkgs.python311}";
    PYTHONBIN = "${pkgs.python311}/bin/python3.11";
    LANG = "en_US.UTF-8";
    STDERREDBIN = "${pkgs.replitPackages.stderred}/bin/stderred";
    PRYBAR_PYTHON_BIN = "${pkgs.replitPackages.prybar-python311}/bin/prybar-python311";
  };  
}

Hey @truongkhoawastaken!

What did you add/change in replit.nix?

It looks like you are trying to use python 3.11
Here’s a few more steps for it to work:

In replit.nix file

From deps, remove:

  • pkgs.replitPackages.prybar-python311
  • pkgs.replitPackages.stderred

From env, remove:

  • PRYBAR_PYTHON_BIN
  • STDERREDBIN

In .replit file

Delete the entire [interpreter] block, possibly lines 15-27
Change channel, possibly on line 13, from "stable-22_11" to "stable-23_05"
In PYTHONPATH, possibly on line 18, update the 2 occurrences of 3.10 to 3.11

In venv folder

In venv/lib folder, rename folder python3.10 to python3.11. This may take a while
In venv/include, if there is one, rename folder python3.10 to python3.11

Refresh

Refresh, or reload the shell, and now your repl runs python 3.11, with a working packages tab

Thank you for your help! But when I install a package , it show this error in pip

~/test$ pip install discord
error: externally-managed-environment

× This environment is externally managed
╰─> This command has been disabled as it tries to modify the immutable
    `/nix/store` filesystem.
    
    To use Python with Nix and nixpkgs, have a look at the online documentation:
    <https://nixos.org/manual/nixpkgs/stable/#python>.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

[notice] A new release of pip is available: 23.0.1 -> 23.2.1
[notice] To update, run: python3.11 -m pip install --upgrade pip

Here’s the .replit file

run = "cowsay Configure me!"

[nix]
channel = "stable-23_05"

[env]
VIRTUAL_ENV = "${REPL_HOME}/venv"
PATH = "${VIRTUAL_ENV}/bin"
PYTHONPATH = "$PYTHONHOME/lib/python3.11:${VIRTUAL_ENV}/lib/python3.11/site-packages"
REPLIT_POETRY_PYPI_REPOSITORY = "https://package-proxy.replit.com/pypi/"
MPLBACKEND = "TkAgg"
POETRY_CACHE_DIR = "${REPL_HOME}/.cache/pypoetry"
POETRY_INSTALLER_MODERN_INSTALLATION = "0"

[debugger]
support = true

  # How to start the debugger.
  [debugger.interactive]
  transport = "localhost:0"
  startCommand = ["dap-python", "main.py"]

    # How to communicate with the debugger.
    [debugger.interactive.integratedAdapter]
    dapTcpAddress = "localhost:0"

    # How to tell the debugger to start a debugging session.
    [debugger.interactive.initializeMessage]
    command = "initialize"
    type = "request"

      [debugger.interactive.initializeMessage.arguments]
      adapterID = "debugpy"
      clientID = "replit"
      clientName = "replit.com"
      columnsStartAt1 = true
      linesStartAt1 = true
      locale = "en-us"
      pathFormat = "path"
      supportsInvalidatedEvent = true
      supportsProgressReporting = true
      supportsRunInTerminalRequest = true
      supportsVariablePaging = true
      supportsVariableType = true

    # How to tell the debugger to start the debuggee application.
    [debugger.interactive.launchMessage]
    command = "attach"
    type = "request"

      [debugger.interactive.launchMessage.arguments]
      logging = {}

# Configures the packager.
[packager]
language = "python3"
ignoredPackages = ["unit_tests"]

  [packager.features]
  enabledForHosting = false
  # Enable searching packages from the sidebar.
  packageSearch = true
  # Enable guessing what packages are needed from the code.
  guessImports = true

Try using poetry add instead of pip install
Or use the convenient packages tab in the IDE

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.