Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3.7 venv fails to create a venv #77614

Closed
Valodim opened this issue Jan 13, 2020 · 8 comments
Closed

python3.7 venv fails to create a venv #77614

Valodim opened this issue Jan 13, 2020 · 8 comments

Comments

@Valodim
Copy link
Contributor

Valodim commented Jan 13, 2020

Describe the bug

python3.7.5 venv fails to create a venv for me.

To Reproduce

$ python3 -m venv .
Error: Command '['/tmp/tmp.mLxXFJyvRk/bin/python3.7', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
$ ls
bin  include  lib  lib64  pyvenv.cfg
$ bin/python3.7 -Im ensurepip --upgrade --default-pip
Looking in links: /tmp/tmp4_tf3pzn
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
ERROR: Could not install packages due to an EnvironmentError: [Errno 30] Read-only file system: '/nix/store/k5rdcbcwwpvj7l9f1yvd5mfggcfz16kk-python3-3.7.5/lib/python3.7/site-packages/easy_install.py'

Expected behavior

A working venv :)

virtualenv does work as expected

Metadata

  • system: "x86_64-linux"
  • host os: Linux 5.4.8, NixOS, 19.09.1806.b047b7315d8 (Loris)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.3.2
  • channels(valodim): "home-manager-19.09, nixpkgs-19.09.1850.5dc4d071ffe"
  • channels(root): "nixos-19.09.1850.5dc4d071ffe"
  • nixpkgs: /home/valodim/.nix-defexpr/channels/nixpkgs

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute: python37
# a list of nixos modules affected by the problem
module:
@jonringer
Copy link
Contributor

jonringer commented Jan 14, 2020

pip is special in venv, most other packages should work fine, also, the workflow is:

$ nix-shell -p python3Packages.virtualenv
$ virtualenv venv
...
$ source ./venv/bin/activate

@jonringer
Copy link
Contributor

related: #77569

@Valodim
Copy link
Contributor Author

Valodim commented Jan 14, 2020

so it's expected behavior that python -m venv . fails? the documentation created in #77569 reads like exactly that call should still work, and it desn't look like anything special is added to the environment for that.

@jonringer
Copy link
Contributor

at least on unstable, this works for me

[07:38:49] jon@jon-desktop /home/jon/projects/nixpkgs (master)
$ nix-shell -p python3Packages.virtualenv

[nix-shell:/home/jon/projects/nixpkgs]$ python -m venv venv

[nix-shell:/home/jon/projects/nixpkgs]$ ls
COPYING  default.nix  doc  lib  maintainers  nixos  pkgs  README.md  venv

[nix-shell:/home/jon/projects/nixpkgs]$ source venv/bin/activate
bash: hash: hashing disabled
bash: hash: hashing disabled
(venv)
[nix-shell:/home/jon/projects/nixpkgs]$ pip install requests
Collecting requests
  Using cached https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests)
  Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests)
  Downloading https://files.pythonhosted.org/packages/b4/40/a9837291310ee1ccc242ceb6ebfd9eb21539649f193a7c8c86ba15b98539/urllib3-1.25.7-py2.py3-none-any.whl (125kB)
     |████████████████████████████████| 133kB 11.2MB/s
Collecting certifi>=2017.4.17 (from requests)
  Downloading https://files.pythonhosted.org/packages/b9/63/df50cac98ea0d5b006c55a399c3bf1db9da7b5a24de7890bc9cfd5dd9e99/certifi-2019.11.28-py2.py3-none-any.whl (156kB)
     |████████████████████████████████| 163kB 15.3MB/s
Collecting idna<2.9,>=2.5 (from requests)
  Using cached https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl
Installing collected packages: chardet, urllib3, certifi, idna, requests
Successfully installed certifi-2019.11.28 chardet-3.0.4 idna-2.8 requests-2.22.0 urllib3-1.25.7
WARNING: You are using pip version 19.2.3, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(venv)
[nix-shell:/home/jon/projects/nixpkgs]$

@jonringer
Copy link
Contributor

just confirmed it works on release-19.09

please do

nix-channels --update
sudo !!

to update your nixpkgs and nixos channels

@jonringer
Copy link
Contributor

the other thing that could be happening is that a pip package from the outer scope exists, in which case you could just do:

nix-shell --pure -p python3Packages.virtualenv

and it will remove everything but what you specified, however, this will remove anything else you had in your previous env

@Valodim
Copy link
Contributor Author

Valodim commented Jan 16, 2020

Yup, works again. Very odd. I had done nix-channel --update very recently. Guess it vanished with an update. Thanks for looking into it :)

@Valodim Valodim closed this as completed Jan 16, 2020
@GuillaumeDesforges
Copy link
Contributor

Issue sometimes happen again. Using virtualenv .venv instead of python -m venv .venv is indeed a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants