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

Creating a 'venv' virtual environment fails when it is unable to find Python. #10822

Closed
tcrory opened this issue Apr 11, 2019 · 54 comments
Closed

Comments

@tcrory
Copy link

tcrory commented Apr 11, 2019

Actual Behavior

When attempting to create a virtual environment using the command python -m venv env, the creation of the virtual environment will fail when venv is unable to find python. When this occurs, it throws an "Errno 2" and reports a problem with the following path:
%LOCALAPPDATA%\Continuum\anaconda3\Lib\venv\scripts\nt\python.exe

Expected Behavior

Python should be able to successfully create a virtual environment using the venv module without any errors.

Steps to Reproduce

  1. Install Anaconda3 2019.03 for 32-bit Windows.
  2. Create a new virtual environment using the command python -m venv env
Anaconda or Miniconda version:

Anaconda3-2019.03-Windows-x86.exe

Operating System:
conda info
Have since downgraded to version Anaconda3-2018.12-Windows-x86.exe which seems to have resolved the issue. Here is the 'conda info' using that version.
     active environment : base
    active env location : C:\Users\{USERNAME}\AppData\Local\Continuum\anaconda3
            shell level : 1
       user config file : C:\Users\{USERNAME}\.condarc
 populated config files : C:\Users\{USERNAME}\.condarc
          conda version : 4.5.12
    conda-build version : 3.17.6
         python version : 3.7.1.final.0
       base environment : C:\Users\{USERNAME}\AppData\Local\Continuum\anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/win-32
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/win-32
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/win-32
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/win-32
                          https://repo.anaconda.com/pkgs/pro/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-32
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Users\{USERNAME}\AppData\Local\Continuum\anaconda3\pkgs
                          C:\Users\{USERNAME}\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\{USERNAME}\AppData\Local\Continuum\anaconda3\envs
                          C:\Users\{USERNAME}\AppData\Local\conda\conda\envs
                          C:\Users\{USERNAME}\.conda\envs
               platform : win-32
             user-agent : conda/4.5.12 requests/2.21.0 CPython/3.7.1 Windows/10 Windows/10.0.17134
          administrator : False
             netrc file : None
           offline mode : False
conda list --show-channel-urls
Have since downgraded to version Anaconda3-2018.12-Windows-x86.exe which seems to have resolved the issue. Here is the 'conda list --show-channel-urls' using that version.
# packages in environment at C:\Users\{USERNAME}\AppData\Local\Continuum\anaconda3:
#
# Name                    Version                   Build  Channel
_ipyw_jlab_nb_ext_conf    0.1.0                    py37_0    defaults
alabaster                 0.7.12                   py37_0    defaults
anaconda                  2018.12                  py37_0    defaults
anaconda-client           1.7.2                    py37_0    defaults
anaconda-navigator        1.9.6                    py37_0    defaults
anaconda-project          0.8.2                    py37_0    defaults
asn1crypto                0.24.0                   py37_0    defaults
astroid                   2.1.0                    py37_0    defaults
astropy                   3.1              py37he774522_0    defaults
atomicwrites              1.2.1                    py37_0    defaults
attrs                     18.2.0           py37h28b3542_0    defaults
babel                     2.6.0                    py37_0    defaults
backcall                  0.1.0                    py37_0    defaults
backports                 1.0                      py37_1    defaults
backports.os              0.1.1                    py37_0    defaults
backports.shutil_get_terminal_size 1.0.0                    py37_2    defaults
beautifulsoup4            4.6.3                    py37_0    defaults
bitarray                  0.8.3            py37hfa6e2cd_0    defaults
bkcharts                  0.2                      py37_0    defaults
blas                      1.0                         mkl    defaults
blaze                     0.11.3                   py37_0    defaults
bleach                    3.0.2                    py37_0    defaults
blosc                     1.14.4               he51fdeb_0    defaults
bokeh                     1.0.2                    py37_0    defaults
boto                      2.49.0                   py37_0    defaults
bottleneck                1.2.1            py37h452e1ab_1    defaults
bzip2                     1.0.6                hfa6e2cd_5    defaults
ca-certificates           2018.03.07                    0    defaults
certifi                   2018.11.29               py37_0    defaults
cffi                      1.11.5           py37h74b6da3_1    defaults
chardet                   3.0.4                    py37_1    defaults
click                     7.0                      py37_0    defaults
cloudpickle               0.6.1                    py37_0    defaults
clyent                    1.2.2                    py37_1    defaults
colorama                  0.4.1                    py37_0    defaults
comtypes                  1.1.7                    py37_0    defaults
conda                     4.5.12                   py37_0    defaults
conda-build               3.17.6                   py37_0    defaults
conda-env                 2.6.0                         1    defaults
conda-verify              3.1.1                    py37_0    defaults
console_shortcut          0.1.1                         3    defaults
contextlib2               0.5.5                    py37_0    defaults
cryptography              2.4.2            py37h7a1dbc1_0    defaults
curl                      7.63.0            h2a8f88b_1000    defaults
cycler                    0.10.0                   py37_0    defaults
cython                    0.29.2           py37ha925a31_0    defaults
cytoolz                   0.9.0.1          py37hfa6e2cd_1    defaults
dask                      1.0.0                    py37_0    defaults
dask-core                 1.0.0                    py37_0    defaults
datashape                 0.5.4                    py37_1    defaults
decorator                 4.3.0                    py37_0    defaults
defusedxml                0.5.0                    py37_1    defaults
distributed               1.25.1                   py37_0    defaults
docutils                  0.14                     py37_0    defaults
entrypoints               0.2.3                    py37_2    defaults
et_xmlfile                1.0.1                    py37_0    defaults
fastcache                 1.0.2            py37hfa6e2cd_2    defaults
filelock                  3.0.10                   py37_0    defaults
flask                     1.0.2                    py37_1    defaults
flask-cors                3.0.7                    py37_0    defaults
freetype                  2.9.1                ha9979f8_1    defaults
future                    0.17.1                   py37_0    defaults
get_terminal_size         1.0.0                h4b36c58_0    defaults
gevent                    1.3.7            py37he774522_1    defaults
glob2                     0.6                      py37_1    defaults
greenlet                  0.4.15           py37hfa6e2cd_0    defaults
h5py                      2.8.0            py37h3bdd7fb_2    defaults
hdf5                      1.10.2               hac2f561_2    defaults
heapdict                  1.0.0                    py37_2    defaults
html5lib                  1.0.1                    py37_0    defaults
icc_rt                    2019.0.0             h0cc432a_1    defaults
icu                       58.2                 h3fcc66b_1    defaults
idna                      2.8                      py37_0    defaults
imageio                   2.4.1                    py37_0    defaults
imagesize                 1.1.0                    py37_0    defaults
importlib_metadata        0.6                      py37_0    defaults
intel-openmp              2019.1                      144    defaults
ipykernel                 5.1.0            py37h39e3cac_0    defaults
ipython                   7.2.0            py37h39e3cac_0    defaults
ipython_genutils          0.2.0                    py37_0    defaults
ipywidgets                7.4.2                    py37_0    defaults
isort                     4.3.4                    py37_0    defaults
itsdangerous              1.1.0                    py37_0    defaults
jdcal                     1.4                      py37_0    defaults
jedi                      0.13.2                   py37_0    defaults
jinja2                    2.10                     py37_0    defaults
jpeg                      9b                   he27b436_2    defaults
jsonschema                2.6.0                    py37_0    defaults
jupyter                   1.0.0                    py37_7    defaults
jupyter_client            5.2.4                    py37_0    defaults
jupyter_console           6.0.0                    py37_0    defaults
jupyter_core              4.4.0                    py37_0    defaults
jupyterlab                0.35.3                   py37_0    defaults
jupyterlab_server         0.2.0                    py37_0    defaults
keyring                   17.0.0                   py37_0    defaults
kiwisolver                1.0.1            py37h6538335_0    defaults
krb5                      1.16.1               hc04afaa_7    defaults
lazy-object-proxy         1.3.1            py37hfa6e2cd_2    defaults
libarchive                3.3.3                h0643e63_5    defaults
libcurl                   7.63.0            h2a8f88b_1000    defaults
libiconv                  1.15                 hc4a7105_7    defaults
libpng                    1.6.35               h2a8f88b_0    defaults
libsodium                 1.0.16               h9d3ae62_0    defaults
libssh2                   1.8.0                h7a1dbc1_4    defaults
libtiff                   4.0.9                h36446d0_2    defaults
libxml2                   2.9.8                hadb2253_1    defaults
libxslt                   1.1.32               hf6f1972_0    defaults
llvmlite                  0.26.0           py37ha925a31_0    defaults
locket                    0.2.0                    py37_1    defaults
lxml                      4.2.5            py37hef2cd61_0    defaults
lz4-c                     1.8.1.2              h2fa13f4_0    defaults
lzo                       2.10                 h00ab751_2    defaults
m2w64-gcc-libgfortran     5.3.0                         6    defaults
m2w64-gcc-libs            5.3.0                         7    defaults
m2w64-gcc-libs-core       5.3.0                         7    defaults
m2w64-gmp                 6.1.0                         2    defaults
m2w64-libwinpthread-git   5.0.0.4634.697f757               2    defaults
markupsafe                1.1.0            py37he774522_0    defaults
matplotlib                3.0.2            py37hc8f65d3_0    defaults
mccabe                    0.6.1                    py37_1    defaults
menuinst                  1.4.14           py37hfa6e2cd_0    defaults
mistune                   0.8.4            py37he774522_0    defaults
mkl                       2019.1                      144    defaults
mkl-service               1.1.2            py37hb782905_5    defaults
mkl_fft                   1.0.6            py37h6288b17_0    defaults
mkl_random                1.0.2            py37h343c172_0    defaults
more-itertools            4.3.0                    py37_0    defaults
mpmath                    1.1.0                    py37_0    defaults
msgpack-python            0.5.6            py37he980bc4_1    defaults
msys2-conda-epoch         20160418                      1    defaults
multipledispatch          0.6.0                    py37_0    defaults
navigator-updater         0.2.1                    py37_0    defaults
nbconvert                 5.4.0                    py37_1    defaults
nbformat                  4.4.0                    py37_0    defaults
networkx                  2.2                      py37_1    defaults
nltk                      3.4                      py37_1    defaults
nose                      1.3.7                    py37_2    defaults
notebook                  5.7.4                    py37_0    defaults
numba                     0.41.0           py37hf9181ef_0    defaults
numexpr                   2.6.8            py37hdce8814_0    defaults
numpy                     1.15.4           py37h19fb1c0_0    defaults
numpy-base                1.15.4           py37hc3f5095_0    defaults
numpydoc                  0.8.0                    py37_0    defaults
odo                       0.5.1                    py37_0    defaults
olefile                   0.46                     py37_0    defaults
openpyxl                  2.5.12                   py37_0    defaults
openssl                   1.1.1a               he774522_0    defaults
packaging                 18.0                     py37_0    defaults
pandas                    0.23.4           py37h830ac7b_0    defaults
pandoc                    1.19.2.1             hb2460c7_1    defaults
pandocfilters             1.4.2                    py37_1    defaults
parso                     0.3.1                    py37_0    defaults
partd                     0.3.9                    py37_0    defaults
path.py                   11.5.0                   py37_0    defaults
pathlib2                  2.3.3                    py37_0    defaults
patsy                     0.5.1                    py37_0    defaults
pep8                      1.7.1                    py37_0    defaults
pickleshare               0.7.5                    py37_0    defaults
pillow                    5.3.0            py37hdc69c19_0    defaults
pip                       18.1                     py37_0    defaults
pkginfo                   1.4.2                    py37_1    defaults
pluggy                    0.8.0                    py37_0    defaults
ply                       3.11                     py37_0    defaults
prometheus_client         0.5.0                    py37_0    defaults
prompt_toolkit            2.0.7                    py37_0    defaults
psutil                    5.4.8            py37he774522_0    defaults
py                        1.7.0                    py37_0    defaults
pycodestyle               2.4.0                    py37_0    defaults
pycosat                   0.6.3            py37hfa6e2cd_0    defaults
pycparser                 2.19                     py37_0    defaults
pycrypto                  2.6.1            py37hfa6e2cd_9    defaults
pycurl                    7.43.0.2         py37h7a1dbc1_0    defaults
pyflakes                  2.0.0                    py37_0    defaults
pygments                  2.3.1                    py37_0    defaults
pylint                    2.2.2                    py37_0    defaults
pyodbc                    4.0.25           py37ha925a31_0    defaults
pyopenssl                 18.0.0                   py37_0    defaults
pyparsing                 2.3.0                    py37_0    defaults
pyqt                      5.9.2            py37h6538335_0    defaults
pysocks                   1.6.8                    py37_0    defaults
pytables                  3.4.4            py37he6f6034_0    defaults
pytest                    4.0.2                    py37_0    defaults
pytest-arraydiff          0.3              py37h39e3cac_0    defaults
pytest-astropy            0.5.0                    py37_0    defaults
pytest-doctestplus        0.2.0                    py37_0    defaults
pytest-openfiles          0.3.1                    py37_0    defaults
pytest-remotedata         0.3.1                    py37_0    defaults
python                    3.7.1                h8c8aaf0_6    defaults
python-dateutil           2.7.5                    py37_0    defaults
python-libarchive-c       2.8                      py37_6    defaults
pytz                      2018.7                   py37_0    defaults
pywavelets                1.0.1            py37h8c2d366_0    defaults
pywin32                   223              py37hfa6e2cd_1    defaults
pywinpty                  0.5.5                 py37_1000    defaults
pyyaml                    3.13             py37hfa6e2cd_0    defaults
pyzmq                     17.1.2           py37hfa6e2cd_0    defaults
qt                        5.9.7            vc14h73c81de_0  [vc14]  defaults
qtawesome                 0.5.3                    py37_0    defaults
qtconsole                 4.4.3                    py37_0    defaults
qtpy                      1.5.2                    py37_0    defaults
requests                  2.21.0                   py37_0    defaults
rope                      0.11.0                   py37_0    defaults
ruamel_yaml               0.15.46          py37hfa6e2cd_0    defaults
scikit-image              0.14.1           py37ha925a31_0    defaults
scikit-learn              0.20.1           py37h343c172_0    defaults
scipy                     1.1.0            py37h29ff71c_2    defaults
seaborn                   0.9.0                    py37_0    defaults
send2trash                1.5.0                    py37_0    defaults
setuptools                40.6.3                   py37_0    defaults
simplegeneric             0.8.1                    py37_2    defaults
singledispatch            3.4.0.3                  py37_0    defaults
sip                       4.19.8           py37h6538335_0    defaults
six                       1.12.0                   py37_0    defaults
snappy                    1.1.7                h8327587_3    defaults
snowballstemmer           1.2.1                    py37_0    defaults
sortedcollections         1.0.1                    py37_0    defaults
sortedcontainers          2.1.0                    py37_0    defaults
sphinx                    1.8.2                    py37_0    defaults
sphinxcontrib             1.0                      py37_1    defaults
sphinxcontrib-websupport  1.1.0                    py37_1    defaults
spyder                    3.3.2                    py37_0    defaults
spyder-kernels            0.3.0                    py37_0    defaults
sqlalchemy                1.2.15           py37he774522_0    defaults
sqlite                    3.26.0               he774522_0    defaults
statsmodels               0.9.0            py37h452e1ab_0    defaults
sympy                     1.3                      py37_0    defaults
tblib                     1.3.2                    py37_0    defaults
terminado                 0.8.1                    py37_1    defaults
testpath                  0.4.2                    py37_0    defaults
tk                        8.6.8                hfa6e2cd_0    defaults
toolz                     0.9.0                    py37_0    defaults
tornado                   5.1.1            py37hfa6e2cd_0    defaults
tqdm                      4.28.1           py37h28b3542_0    defaults
traitlets                 4.3.2                    py37_0    defaults
unicodecsv                0.14.1                   py37_0    defaults
urllib3                   1.24.1                   py37_0    defaults
vc                        14.1                 h0510ff6_4    defaults
vs2015_runtime            14.15.26706          h3a45250_0    defaults
wcwidth                   0.1.7                    py37_0    defaults
webencodings              0.5.1                    py37_1    defaults
werkzeug                  0.14.1                   py37_0    defaults
wheel                     0.32.3                   py37_0    defaults
widgetsnbextension        3.4.2                    py37_0    defaults
win_inet_pton             1.0.1                    py37_1    defaults
win_unicode_console       0.5                      py37_0    defaults
wincertstore              0.2                      py37_0    defaults
winpty                    0.4.3                         4    defaults
wrapt                     1.10.11          py37hfa6e2cd_2    defaults
xlrd                      1.2.0                    py37_0    defaults
xlsxwriter                1.1.2                    py37_0    defaults
xlwings                   0.15.1                   py37_0    defaults
xlwt                      1.3.0                    py37_0    defaults
xz                        5.2.4                h2fa13f4_4    defaults
yaml                      0.1.7                h896c600_2    defaults
zeromq                    4.2.5                he025d50_1    defaults
zict                      0.1.3                    py37_0    defaults
zlib                      1.2.11               h62dcd97_3    defaults
zstd                      1.3.7                h508b16e_0    defaults
@tcrory
Copy link
Author

tcrory commented Apr 11, 2019

This functionality was working in both command prompts and conda prompts earlier today. After updating using conda update conda and conda update anaconda, this functionality began to fail in both prompts.

This functionality continued to fail after uninstalling and reinstalling using the latest installer for Anaconda 3 on 32-bit Windows.

This functionality was restored after uninstalling version 2019.03 and then installing version 2018.12 and again works in both command prompts and conda prompts.

@AugustusKwan
Copy link

I encountered the same problem. I have to reinstall the version 2018.12.Otherwise, I am not about to create the virtual environment with the 'venv' command.

@brendano257
Copy link

brendano257 commented Apr 16, 2019

I'm having the same problem with creating venv environments in PyCharm Community 2019 on a 64-bit install of both PyCharm and Anaconda, the full PyCharm traceback is:

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.1\helpers\packaging_tool.py", line 170, in main
    do_pyvenv(path, system_site_packages)
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.1\helpers\packaging_tool.py", line 88, in do_pyvenv
    venv.create(path, system_site_packages=system_site_packages)
  File "C:\ProgramData\Anaconda3\lib\venv\__init__.py", line 363, in create
    builder.create(env_dir)
  File "C:\ProgramData\Anaconda3\lib\venv\__init__.py", line 66, in create
    self.setup_python(context)
  File "C:\ProgramData\Anaconda3\lib\venv\__init__.py", line 204, in setup_python
    copier(context.executable, path)
  File "C:\ProgramData\Anaconda3\lib\venv\__init__.py", line 192, in symlink_or_copy
    shutil.copyfile(src, dst)
  File "C:\ProgramData\Anaconda3\lib\shutil.py", line 120, in copyfile
    with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\ProgramData\\Anaconda3\\lib\\venv\\scripts\\nt\\python.exe'

@msarahan
Copy link
Contributor

Thanks for the report. We believe this may be a problem with our venv/virtualenv packages. We will investigate as soon as we are able.

@msarahan
Copy link
Contributor

In the meantime, you might want to try creating conda environments. There's a tab on the left side to choose.

@gauss200
Copy link

Conda environments work for 2019 64 bit but jupyter notebooks don't work for conda just venv.

@mingwandroid
Copy link

jupyter notebooks don't work for conda just venv

AFAIK this is not the case, what makes you say so?

@mingwandroid
Copy link

Thanks for the report. This should be fixed now. If you can help test [*] via:

conda update -c c3i_test2 python

.. we'd appreciate it.

[*] this package was built securely and is a release candidate if that placates any security concerns.

@tcrory
Copy link
Author

tcrory commented Apr 25, 2019 via email

@adrzystek
Copy link

I have the same problem while creating project interpreter (ie. virtual environment) via Pycharm Community Edition 2019.1.1. The command output is the same as given a few answers above by brendano257 (FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\xxx\\Anaconda3\\lib\\venv\\scripts\\nt\\python.exe').

I did conda update conda and conda update anaconda but nothing changed.

conda info trace:

active environment : base
active env location : C:\Users\xxx\Anaconda3
shell level : 1
user config file : C:\Users\xxx.condarc
populated config files : C:\Users\xxx.condarc
conda version : 4.6.14
conda-build version : 3.17.8
python version : 3.7.3.final.0
base environment : C:\Users\xxx\Anaconda3 (writable)
channel URLs : https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/free/win-64
https://repo.anaconda.com/pkgs/free/noarch
https://repo.anaconda.com/pkgs/r/win-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/msys2/win-64
https://repo.anaconda.com/pkgs/msys2/noarch
package cache : C:\Users\xxx\Anaconda3\pkgs
C:\Users\xxx.conda\pkgs
C:\Users\xxx\AppData\Local\conda\conda\pkgs
envs directories : C:\Users\xxx\Anaconda3\envs
C:\Users\xxx.conda\envs
C:\Users\xxx\AppData\Local\conda\conda\envs
platform : win-64
user-agent : conda/4.6.14 requests/2.21.0 CPython/3.7.3 Windows/7 Windows/6.1.7601
administrator : False
netrc file : None
offline mode : False

Could we hope for making it work? :(

@mingwandroid
Copy link

I did conda update conda and conda update anaconda but nothing changed.

You should use conda update python

@adrzystek
Copy link

Thanks for a quick response.

Now, however, I get:

image

(running Pycharm as administrator doesn't help)

@jleen
Copy link

jleen commented Apr 29, 2019

I am hitting this issue with python -m venv foo returning a No such file or directory error with Python 3.7 in Anaconda 2019.3. I tried conda update -c c3i_test2 python but it makes no difference. Is there something else I should try? Is there any debugging information I could provide that would be useful?

@tcrory
Copy link
Author

tcrory commented Apr 29, 2019

I tested the fix on 32-bit anaconda 3, using the command conda update -c c3i_test2 python.

The fix worked well for me. I was able to create, activate, and update a virtual environment using venv without any issues. You could possibly try using --force-reinstall when doing the update to see if it helps?

@jleen
Copy link

jleen commented Apr 29, 2019

Hmm, I'm on 64-bit. Maybe that's the difference?

@mingwandroid
Copy link

conda update -c c3i_test2 python
#10822 (comment)

Do not use c3i_test2, the packages are available in defaults.

@chrisleaman
Copy link

I'm also seeing this issue on 64-bit conda 4.6.14. I've tried updating as per suggestions above, but no luck.

@jleen
Copy link

jleen commented May 1, 2019

Agreed with Chris. On 64-bit, conda update conda, conda update anaconda, and conda update python have all been no help in resolving this issue. I've resorted to downgrading to the previous version of the distribution.

@mingwandroid
Copy link

Sorry, I cannot reproduce this. Can someone still having trouble (after conda update python) please show the output from:

conda list --show-channel-urls | findstr python

We want to see in there:

python                    3.7.3                h8c8aaf0_1    defaults

If you verify that is the version you have installed then please retry python -m venv venv.

@jleen
Copy link

jleen commented May 1, 2019

Thanks, mingwandroid. I followed your advice and it has unblocked me for the time being. It did lead to a concerning side-effect, however.

I had python h8c8aaf0_0. I did a conda update python and got the curious warning that anaconda would be DOWNGRADED 2019.03-py37_0 --> custom-py37_0. Is this expected?

In any case it does do the job. I now have python h8c8aaf0_1 and my python -m venv succeeds, yay!

However, the DOWNGRADE is a little alarming, and a conda update --all now tells me it wants to upgrade my anaconda and, sigh, downgrade my python, which would put me back where I started.

I'm glad that my venv is unblocked for now, but it's a little worrying that I cannot do an update --all safely. When should I expect this to be fixed?

@msarahan
Copy link
Contributor

msarahan commented May 1, 2019

anaconda is a metapackage, representing a pinned state. That it changes to custom is of no concern - it just means that it's not the tested configuration that we released. Since anyone can change any package, it's impossible to test every possible combination.

You can actually remove the anaconda metapackage with no consequence. It served its purpose in providing you with your initial set of packages. Removing it will allow update --all to work. No fix is necessary.

@jleen
Copy link

jleen commented May 1, 2019

@msarahan You're right of course. Thanks. I did conda remove anaconda and now my conda update --all behaves sanely… and my python -m venv foo succeeds afterwards, too. Thank you!

@nachiketrss
Copy link

nachiketrss commented Mar 12, 2020

Hi I am facing this issue while creating virtual environment using venv.

python -m venv venv_name

Error: [Errno 2] No such file or directory: 'C:\ProgramData\Anaconda3\lib\venv\scripts\nt\python.exe'

My python and conda versons are Python 3.7.3 and conda 4.6.11 respectively.

What is the solution to this? Some are suggesting to use 'conda update python'. I believe this command will upgrade my python to higher version. What if I wish to stick to the same version of python but need this issue fixed. Is this possible please?

@mingwandroid
Copy link

You are not using the latest python nor conda versions. Issues with venv were fixed in more recent versions. You need to simply update your software. Another thing you may want to take care about is to use only "The Anaconda Prompt", or to activate your base env correctly.

I tested with Python 3.7.4 and 4.7.12 and the following worked fine:

call C:\opt\conda\Scripts\activate
python -m venv env2
call env2\Scripts\activate.bat
where python
C:\Users\rdonnelly\env2\Scripts\python.exe

@nachiketrss
Copy link

nachiketrss commented Mar 13, 2020

@mingwandroid -

  1. Isn't the base environment already activated when the anaconda prompt is opened.
  2. How can I upgrade conda while still keeping the same python version? - conda update conda?

@mingwandroid
Copy link

How can I upgrade conda while still keeping the same python version? - conda update conda?

The venv fix is only in later python version and builds. Why don't you want to update python here? Conda will not update from 3.7 to 3.8 without you explicitly requesting that.

@mingwandroid
Copy link

If you use the anaconda prompt then yes activation is done for you already. I wanted the instructions to be as general as possible though and double activation is not a problem.

@nachiketrss
Copy link

Ok thanks - please can you confirm that the root cause of the issue is the python version and not the anaconda version? If that is the case, then why does venv work when I use the same python version without anaconda? Probably there is some conflict between anaconda and python?

@mingwandroid
Copy link

mingwandroid commented Mar 13, 2020

I have not checked the exact package versions but for the third time, yes this is the case) the bug was in our python builds and I personally fixed it a long time ago. Our python builds (and the builds from most other distributions) contain many changes from the official releases and sometimes those changes cause bugs. That's what happened here.

If you report a bug against old software versions and/or builds, it is ideal if you can test with the latest versions and report on the results in the bug report.

People sometimes think sticking to an exact python build is necessary when it really isn't and isn't in general advisable. CVE fixes are not always backported to old versions and when they are backported they still require a new build of that python minor version and for the end user to update to that version in order for the safeguards to take affect.

Why do you think sticking to 3.7.3 is important. I should also note that you didn't give the build number so I wouldn't be able to tell you whether your installed python version has this bug or not. That info is given by conda list.

@nachiketrss
Copy link

@mingwandroid - its python 3.7.3 - h8c8aaf0_0

@basavarajsh98
Copy link

basavarajsh98 commented Oct 17, 2020

@tcrory Following steps worked for me:

  1. Copy python.exe and pythonw.exe from C:\ProgramData\Anaconda3
  2. Paste them in C:\ProgramData\Anaconda3\Lib\venv\scripts\nt

Hit +1 if it worked for anyone else.

PS: Yes I did try all the methods mentioned above by others and nothing worked for me.

@jphme
Copy link

jphme commented Oct 18, 2020

I just got the error message with Python 3.8. and the current anaconda version. However, the command python -m venv env doesn't throw the error, pipenv install does.

>pipenv install
Creating a virtualenv for this project…
Pipfile: D:\dev2\xyz\Pipfile
Using D:/Anaconda3/python.exe (3.8.6) to create virtualenv…
[ ===] Creating virtual environment...FileNotFoundError: [Errno 2] No such file or directory: 'D:\\Anaconda3\\Lib\\venv\\scripts\\nt\\python.exe'

Failed creating virtual environment

Conda info:

     active environment : None
       user config file : C:\Users\xyz\.condarc
 populated config files : C:\Users\xyz\.condarc
          conda version : 4.9.0
    conda-build version : not installed
         python version : 3.8.6.final.0
       virtual packages : __cuda=11.0=0
                          __win=0=0
                          __archspec=1=x86_64
       base environment : D:\Anaconda3  (writable)
           channel URLs : https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : D:\Anaconda3\pkgs
                          C:\Users\xyz\.conda\pkgs
                          C:\Users\xyz\AppData\Local\conda\conda\pkgs
       envs directories : D:\Anaconda3\envs
                          C:\Users\xyz\.conda\envs
                          C:\Users\xyz\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.9.0 requests/2.24.0 CPython/3.8.6 Windows/10 Windows/10.0.19041
          administrator : False
             netrc file : None
           offline mode : False

@basavarajsh98
Copy link

basavarajsh98 commented Oct 19, 2020

@jpdus Try this:

  1. Copy python.exe and pythonw.exe from D:\Anaconda3
  2. Paste them in D:\Anaconda3\Lib\venv\scripts\nt
  3. Now run, pipenv install

Hope it works 👍

@jphme
Copy link

jphme commented Oct 19, 2020

Thanks, solved it by downgrading virtualenv to 20.0.33 .

@SangamSwadiK
Copy link

@basavarajsh98 Thanks it works !!

@catris25
Copy link

catris25 commented Nov 3, 2020

@jpdus Try this:

  1. Copy python.exe and pythonw.exe from D:\Anaconda3
  2. Paste them in D:\Anaconda3\Lib\venv\scripts\nt
  3. Now run, pipenv install

Hope it works 👍

I had the same problem, and this worked. Thanks a lot!

@CharlesGaydon
Copy link

Thanks, solved it by downgrading virtualenv to 20.0.33 .

This was the easiest fix, which worked for me. Solution involving copying python.exe files did not.

Context: conda 4.9.2, Python 3.7.9, creating a venv by using pre-commit

@NaoyaHamazaki
Copy link

Thank you!(from Japan)

@asears
Copy link

asears commented Dec 16, 2020

Should this issue be reopened? Experiencing same issue when running tox. Can workaround by copying python executables or downgrading virtualenv however both are just workarounds and do not necessarily fix broken Conda + virtualenv.

I think there's some assumptions here that require a test for presence of python.exe and fallback mechanism, or some changes to creation of the conda environment process to match updated expectations on Windows.

Does an issue need to be opened in virtualenv project?

It was introduced here in virtualenv 20.0.34.
https://github.com/pypa/virtualenv/pull/1976/files

Possible source:

    @classmethod
    def _executables(cls, interpreter):
        system_exe = Path(interpreter.system_executable)
        if cls.venv_37p(interpreter):
            # starting with CPython 3.7 Windows ships with a venvlauncher.exe that avoids the need for dll/pyd copies
            launcher = Path(interpreter.system_stdlib) / "venv" / "scripts" / "nt" / "python.exe"
            executables = cls._win_executables(launcher, interpreter, RefWhen.COPY)
            executables = chain(executables, cls._win_executables(system_exe, interpreter, RefWhen.SYMLINK))
        else:
            executables = cls._win_executables(system_exe, interpreter, RefWhen.ANY)
        for src, targets, must, when in executables:
            yield src, targets, must, when

The workaround I used was to open an administrator command prompt and setup symlinks.

set envname=myenv
mklink c:\tools\anaconda3\envs\%envname%\lib\venv\scripts\nt\python.exe c:\tools\anaconda3\envs\%envname%\python.exe
mklink c:\tools\anaconda3\envs\%envname%\lib\venv\scripts\nt\pythonw.exe c:\tools\anaconda3\envs\%envname%\pythonw.exe

@jmahlik
Copy link

jmahlik commented Dec 16, 2020

Should this issue be reopened? Experiencing same issue when running tox. Can workaround by copying python executables or downgrading virtualenv however both are just workarounds and do not necessarily fix broken Conda + virtualenv.

I think there's some assumptions here that require a test for presence of python.exe and fallback mechanism, or some changes to creation of the conda environment process to match updated expectations on Windows.

Does an issue need to be opened in virtualenv project?

It was introduced here in virtualenv 20.0.34.
https://github.com/pypa/virtualenv/pull/1976/files

Possible source:

    @classmethod
    def _executables(cls, interpreter):
        system_exe = Path(interpreter.system_executable)
        if cls.venv_37p(interpreter):
            # starting with CPython 3.7 Windows ships with a venvlauncher.exe that avoids the need for dll/pyd copies
            launcher = Path(interpreter.system_stdlib) / "venv" / "scripts" / "nt" / "python.exe"
            executables = cls._win_executables(launcher, interpreter, RefWhen.COPY)
            executables = chain(executables, cls._win_executables(system_exe, interpreter, RefWhen.SYMLINK))
        else:
            executables = cls._win_executables(system_exe, interpreter, RefWhen.ANY)
        for src, targets, must, when in executables:
            yield src, targets, must, when

The workaround I used was to open an administrator command prompt and setup symlinks.

set envname=myenv
mklink c:\tools\anaconda3\envs\%envname%\lib\venv\scripts\nt\python.exe c:\tools\anaconda3\envs\%envname%\python.exe
mklink c:\tools\anaconda3\envs\%envname%\lib\venv\scripts\nt\pythonw.exe c:\tools\anaconda3\envs\%envname%\pythonw.exe

Same issue here, from multiple of my collogues. It just started popping up in the last few days, which leads me to suspect it could be something with the most recent virtualenv release. We've been able to resolve it by pinning virtualenv to 20.0.8.

@iUnknwn
Copy link

iUnknwn commented Dec 19, 2020

Same - with a fresh install of miniconda from earlier today (Windows x64, conda version 4.9.2, python 3.8.5), I'm unable to get pipenv to generate an environment:

Creating a virtualenv for this project...
Pipfile: F:\src\proj\server\Pipfile
Using C:/Users/userName/miniconda3/python.exe (3.8.5) to create virtualenv...
[=== ] Creating virtual environment...FileNotFoundError: [Errno 2] No such file or directory: 'c:\\users\\userName\\miniconda3\\Lib\\venv\\scripts\\nt\\python.exe'

Failed creating virtual environment

[pipenv.exceptions.VirtualenvCreationException]:
Failed to create virtual environment.

@mjt91
Copy link

mjt91 commented Dec 22, 2020

Same happens to me with a fresh install of miniconda in conjunction with pyenv. I described my output in the issue linked above. None of the proposed steps here is working for me.

@abravalheri
Copy link

@msarahan, @mingwandroid it looks like there is still an issue when a command automated with tox (running in a conda environment on windows) internally relies on venv. This issue was first reported in pypa/build#253 (the link contains details on how to reproduce the errors).

The use case is: the dev uses conda to create a environment and attempts to automate common tasks with tox, but one of the packages used in the task automation internally uses venv.

Should I create a separated issue for that?

@ofek
Copy link

ofek commented Mar 20, 2022

I'm experiencing the same issue as @abravalheri

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