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

global packages are used instead of local, despite an environment being active. #7230

Closed
1 of 2 tasks
MassiveAtoms opened this issue Apr 28, 2018 · 18 comments
Closed
1 of 2 tasks
Labels
locked [bot] locked due to inactivity

Comments

@MassiveAtoms
Copy link

MassiveAtoms commented Apr 28, 2018

I'm submitting a...

  • bug report
  • feature request

Current Behavior

When running python scripts with an environment activated, it still uses packages from <anaconda install path>\Lib\site-packages\ instead of <anaconda install path>\envs\<env>\Lib\site-packages\

I created a new environment after reading ContinuumIO/anaconda-issues#1429 (comment) , something I came across when trying to solve this, making sure that pip was installed when the environment was created, and it worked fine for a while. Then, it suddenly began to behave like this instead of what I expected. Also, de- and reactivating my env did not solve it.

Steps to Reproduce

created my environment
conda create -n vacatures pip django=1.10.8 mezzanine
activated it(conda activate vacatures), went to work on my project, and when I tried running a script, it used modules from the global/base environment instead.

here's a snippet of my base env list

(base) C:\Users\sagar>conda list
# packages in environment at C:\Anaconda3:
#
# Name                    Version                   Build  Channel
_ipyw_jlab_nb_ext_conf    0.1.0            py36he6757f0_0
...
django                    2.0.2            py36hd476221_0
Django                    2.0.4                     <pip>
django-addressbook        0.1.1                     <pip>
django-addresses          0.1                       <pip>
...

Here's a snippet of the vacatures environment

(base) C:\Users\sagar>conda activate vacatures
(vacatures) C:\Users\sagar>conda list
# packages in environment at C:\Anaconda3\envs\vacatures:
#
# Name                    Version                   Build  Channel
...
django                    1.10.8                     py_0    conda-forge
django-contrib-comments   1.8.0                     <pip>
...

and here's a part of the error

(vacatures) C:\Users\sagar\Desktop\Dev\vizcode_projs\mezzjobs\board>manage.py runserver
...
    from mezzanine.utils.urls import home_slug
  File "C:\Anaconda3\lib\site-packages\mezzanine\utils\urls.py", line 8, in <module>
    from django.core.urlresolvers import (resolve, reverse, NoReverseMatch,
ModuleNotFoundError: No module named 'django.core.urlresolvers'

but django 1.10.8 does have django.core.urlresolvers, unlike django 2.0.4, which is installed in the base env.

Expected Behavior

It should only use packages and modules from the activated environment

Environment Information

`conda info`

     active environment : vacatures
    active env location : C:\Anaconda3\envs\vacatures
            shell level : 2
       user config file : C:\Users\sagar\.condarc
 populated config files : C:\Users\sagar\.condarc
          conda version : 4.5.1
    conda-build version : 3.4.1
         python version : 3.6.4.final.0
       base environment : C:\Anaconda3  (writable)
           channel URLs : https://conda.anaconda.org/auto/win-64
                          https://conda.anaconda.org/auto/noarch
                          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/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/pro/win-64
                          https://repo.anaconda.com/pkgs/pro/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Anaconda3\pkgs
                          C:\Users\sagar\AppData\Local\conda\conda\pkgs
       envs directories : C:\Anaconda3\envs
                          C:\Users\sagar\AppData\Local\conda\conda\envs
                          C:\Users\sagar\.conda\envs
               platform : win-64
             user-agent : conda/4.5.1 requests/2.18.4 CPython/3.6.4 Windows/10 Windows/10.0.16299
          administrator : False
             netrc file : None
           offline mode : False

`conda config --show-sources`

==> C:\Users\sagar\.condarc <==
ssl_verify: True
channels:
  - auto
  - conda-forge
  - defaults

`conda list --show-channel-urls`

(vacatures) C:\Users\sagar\Desktop\Dev\vizcode_projs\mezzjobs\board>conda list --show-channel-urls
# packages in environment at C:\Anaconda3\envs\vacatures:
#
# Name                    Version                   Build  Channel
astroid                   1.6.3                     <pip>
beautifulsoup4            4.6.0                     <pip>
bleach                    2.1.3                     <pip>
certifi                   2018.4.16                py36_0    conda-forge
chardet                   3.0.4                     <pip>
colorama                  0.3.9                     <pip>
django                    1.10.8                     py_0    conda-forge
django-contrib-comments   1.8.0                     <pip>
dodgy                     0.1.9                     <pip>
filebrowser-safe          0.4.7                     <pip>
flake8                    3.5.0                     <pip>
flake8-polyfill           1.0.2                     <pip>
future                    0.16.0                    <pip>
grappelli-safe            0.4.7                     <pip>
html5lib                  1.0.1                     <pip>
idna                      2.6                       <pip>
isort                     4.3.4                     <pip>
lazy-object-proxy         1.3.1                     <pip>
mccabe                    0.6.1                     <pip>
Mezzanine                 4.2.3                     <pip>
oauthlib                  2.0.7                     <pip>
pep8-naming               0.5.0                     <pip>
Pillow                    5.1.0                     <pip>
pip                       9.0.3                    py36_0    conda-forge
prospector                0.12.7                    <pip>
pycodestyle               2.0.0                     <pip>
pydocstyle                2.1.1                     <pip>
pyflakes                  1.6.0                     <pip>
pylint                    1.8.4                     <pip>
pylint-celery             0.3                       <pip>
pylint-common             0.2.5                     <pip>
pylint-django             0.11                      <pip>
pylint-flask              0.5                       <pip>
pylint-plugin-utils       0.2.6                     <pip>
python                    3.6.5                         1    conda-forge
pytz                      2018.4                     py_0    conda-forge
PyYAML                    3.12                      <pip>
requests                  2.18.4                    <pip>
requests-oauthlib         0.8.0                     <pip>
requirements-detector     0.5.2                     <pip>
setoptconf                0.2.0                     <pip>
setuptools                39.0.1                   py36_0    conda-forge
six                       1.11.0                    <pip>
snowballstemmer           1.2.1                     <pip>
tzlocal                   1.5.1                     <pip>
urllib3                   1.22                      <pip>
vs2015_runtime            14.0.25420                    0    conda-forge
webencodings              0.5.1                     <pip>
wheel                     0.31.0                   py36_0    conda-forge
wincertstore              0.2                      py36_0    conda-forge
wrapt                     1.10.11                   <pip>

@kalefranz
Copy link
Contributor

What is the output of where manage.py?

@MassiveAtoms
Copy link
Author

MassiveAtoms commented May 4, 2018

(vacatures) C:\Users\sagar\Desktop\Dev\vizcode_projs\mezzjobs\board>where manage.py
C:\Users\sagar\Desktop\Dev\vizcode_projs\mezzjobs\board\manage.py

(vacatures) C:\Users\sagar\Desktop\Dev\vizcode_projs\mezzjobs\board>cd ../
(vacatures) C:\Users\sagar\Desktop\Dev\vizcode_projs\mezzjobs>where manage.py
INFO: Could not find files for the given pattern(s).

@kalefranz
Copy link
Contributor

Should be resolved in conda 4.6 as part of #7194 through #7195.

@kalefranz
Copy link
Contributor

If you want to try the latest prerelease conda version, use

conda install -n base conda-canary::conda

@MassiveAtoms
Copy link
Author

Thank you, I will be switching to that. I've deleted and recreated envs 3 more times in the last week just because this issue kept popping up.

@MassiveAtoms
Copy link
Author

Hmmmm, I have another problem that just started appearing after I upgraded to conda 4.6.0a2.
I'm unable to use pip install commands in some envs.
Should I create a new bug report?

(chemistry) C:\Users\sagar>pip install django-widget-tweaks
Unable to create process using 'C:\Anaconda3\envs\chemistry\python.exe C:\Anaconda3\envs\chemistry\Scripts\pip-script.py install django-widget-tweaks'
(chemistry) C:\Users\sagar>conda deactivate
C:\Users\sagar>pip install django-widget-tweaks
Requirement already satisfied: django-widget-tweaks in c:\anaconda3\lib\site-packages (1.4.2)
...(bunch of errors about missing orincompatible dependencies that pip installing in the base environment has caused despite some env being active)

@kalefranz
Copy link
Contributor

Yeah if you can come up with a sequence of commands that reproduce the error, so that I can reproduce it myself, I’ll try to figure out what’s going on.

@MassiveAtoms
Copy link
Author

Actually, I can't do that, exactly.
I'm in the process of doing a fresh anaconda install.
But the basic gist of it was,
using conda install -n base conda-canary::conda, creating a new env conda create -n somename pip django=2.0.5 pep8 flake8 prospector django-import-export, starting up vscode, activating the env, then trying to do additional installs with pip.

I suddenly couldn't activate any envs, so I've decided a fresh install is in order.
(yet another issue)
when I tried conda activate env it said something about supported shells, and if I was launching it from a script I should use SOMEWORD conda activate, and something about conda init. This happened both in vscode and in the normal cmd terminal.
I ran conda init, something went wrong, I sent 2 reports to the core developer team.
I'll try to recreate the problem with the fresh install.
I'm sorry I can't help more for now.

@kalefranz
Copy link
Contributor

The error you uploaded the report for was #7256.

@MassiveAtoms
Copy link
Author

MassiveAtoms commented May 5, 2018

Ok, I did a fresh install, moved my old envs back,
upgraded conda

`upgrade output`

C:\Users\sagar>conda install -n base conda-canary::conda
Solving environment: done

## Package Plan ##

  environment location: C:\Anaconda3

  added / updated specs:
    - conda-canary::conda


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    conda-4.6.0a2              |           py36_0         1.2 MB  conda-canary
    certifi-2018.1.18          |           py36_0         144 KB  conda-forge
    yaml-0.1.7                 |           vc14_0         103 KB  conda-forge
    ------------------------------------------------------------
                                           Total:         1.5 MB

The following packages will be UPDATED:

    certifi: 2018.1.18-py36_0 --> 2018.1.18-py36_0 conda-forge
    conda:   4.4.10-py36_0    --> 4.6.0a2-py36_0   conda-canary

The following packages will be DOWNGRADED:

    yaml:    0.1.7-hc54c509_2 --> 0.1.7-vc14_0     conda-forge  [vc14]

Proceed ([y]/n)? y


Downloading and Extracting Packages
conda 4.6.0a2: ################################################################################################ | 100%
certifi 2018.1.18: ############################################################################################ | 100%
yaml 0.1.7: ################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
The batch file cannot be found.


opened vscode, activated my env and tried installing something with pip

C:\Users\sagar\Desktop\Dev\vizcode_projs\chem-soraya>conda activate chemistry
(chemistry) C:\Users\sagar\Desktop\Dev\vizcode_projs\chem-soraya>pip freeze
Unable to create process using 'C:\Anaconda3\envs\chemistry\python.exe C:\Anaconda3\envs\chemistry\Scripts\pip-script.py freeze'

(chemistry) C:\Users\sagar\Desktop\Dev\vizcode_projs\chem-soraya>pip install django-filter
Unable to create process using 'C:\Anaconda3\envs\chemistry\python.exe C:\Anaconda3\envs\chemistry\Scripts\pip-script.py install django-filter'

After that, I tried to activate my env in a normal cmd terminal outside vscode. in there, activate myenv works, but conda activate myenv doesn't

C:\Users\sagar>conda activate chemistry
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If using 'conda activate' from a batch script, change your
invocation to 'CALL conda.bat activate'.

To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - cmd.exe
  - fish
  - tcsh
  - xonsh
  - zsh

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init'.

trying to run conda init cmd.exe does throw an AssertionError again

`Error report`


C:\Users\sagar>CALL conda.bat activate
'conda.bat' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\sagar>conda.bat activate
'conda.bat' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\sagar>conda init cmd.exe

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "C:\Anaconda3\lib\site-packages\conda\exceptions.py", line 875, in __call__
        return func(*args, **kwargs)
      File "C:\Anaconda3\lib\site-packages\conda\cli\main.py", line 83, in _main
        exit_code = do_call(args, p)
      File "C:\Anaconda3\lib\site-packages\conda\cli\conda_argparse.py", line 97, in do_call
        exit_code = getattr(module, func_name)(args, parser)
      File "C:\Anaconda3\lib\site-packages\conda\cli\main_init.py", line 51, in execute
        anaconda_prompt)
      File "C:\Anaconda3\lib\site-packages\conda\core\initialize.py", line 70, in initialize
        run_plan_elevated(plan2)
      File "C:\Anaconda3\lib\site-packages\conda\core\initialize.py", line 487, in run_plan_elevated
        assert rc == 0
    AssertionError

`$ C:\Anaconda3\Scripts\conda-script.py init cmd.exe`

  environment variables:
                 CIO_TEST=<not set>
               CONDA_ROOT=C:\Anaconda3
                 HOMEPATH=\Users\sagar
                     PATH=C:\Program Files (x86)\Python36-32\Scripts\;C:\Program Files (x86)\Pyt
                          hon36-32\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\W
                          indows\System32\WindowsPowerShell\v1.0\;C:\Program
                          Files\Calibre2\;C:\Program Files\Git\cmd;C:\ProgramData\chocolatey\bin
                          ;C:\Anaconda3;C:\Anaconda3\Library\mingw-w64\bin;C:\Anaconda3\Library\
                          usr\bin;C:\Anaconda3\Library\bin;C:\Anaconda3\Scripts;%cd%;C:\Program
                          Files\Microsoft VS Code\bin;C:\Program Files (x86)\Nmap
             PSMODULEPATH=C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\Windows
                          PowerShell\v1.0\Modules
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>

     active environment : None
       user config file : C:\Users\sagar\.condarc
 populated config files : C:\Users\sagar\.condarc
          conda version : 4.6.0a2
    conda-build version : 3.4.1
         python version : 3.6.4.final.0
       base environment : C:\Anaconda3  (writable)
           channel URLs : https://conda.anaconda.org/auto/win-64
                          https://conda.anaconda.org/auto/noarch
                          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/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:\Anaconda3\pkgs
                          C:\Users\sagar\AppData\Local\conda\conda\pkgs
       envs directories : C:\Anaconda3\envs
                          C:\Users\sagar\AppData\Local\conda\conda\envs
                          C:\Users\sagar\.conda\envs
               platform : win-64
             user-agent : conda/4.6.0a2 requests/2.18.4 CPython/3.6.4 Windows/10 Windows/10.0.16299
          administrator : False
             netrc file : None
           offline mode : False


An unexpected error has occurred. Conda has prepared the above report.
If submitted, this report will be used by core maintainers to improve
future releases of conda.
Would you like conda to send this report to the core maintainers?
[y/N]: y
Upload successful.

Thank you for helping to improve conda.
Opt-in to always sending reports (and not see this message again)
by running

    $ conda config --set report_errors true

I guess it might be kinda my fault? Should I do a new fresh install and not select to add anaconda to path? It did mention it might cause problems.

Also,

details, as they have changed somewhat.

`conda info`

(chemistry) C:\Users\sagar>conda info

     active environment : chemistry
    active env location : C:\Anaconda3\envs\chemistry
            shell level : 1
       user config file : C:\Users\sagar\.condarc
 populated config files : C:\Users\sagar\.condarc
          conda version : 4.6.0a2
    conda-build version : 3.4.1
         python version : 3.6.4.final.0
       base environment : C:\Anaconda3  (writable)
           channel URLs : https://conda.anaconda.org/auto/win-64
                          https://conda.anaconda.org/auto/noarch
                          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/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:\Anaconda3\pkgs
                          C:\Users\sagar\AppData\Local\conda\conda\pkgs
       envs directories : C:\Anaconda3\envs
                          C:\Users\sagar\AppData\Local\conda\conda\envs
                          C:\Users\sagar\.conda\envs
               platform : win-64
             user-agent : conda/4.6.0a2 requests/2.18.4 CPython/3.6.4 Windows/10 Windows/10.0.16299
          administrator : False
             netrc file : None
           offline mode : False

`conda list --show-channel-urls`

```

(chemistry) C:\Users\sagar>conda list --show-channel-urls

packages in environment at C:\Anaconda3\envs\chemistry:

Name Version Build Channel

asn1crypto 0.24.0 py35_0 conda-forge
astroid 1.6.3 py35_0 conda-forge
bunch 1.0.1
ca-certificates 2018.4.16 0 conda-forge
certifi 2018.4.16 py35_0 conda-forge
cffi 1.11.5 py35_0 conda-forge
chardet 3.0.4 py35_0 conda-forge
colorama 0.3.9 py35_0 conda-forge
cryptography 2.2.1 py35_0 conda-forge
diff-match-patch 20121119 py35_0 conda-forge
django 2.0.5 py35hd476221_0 conda-forge
Django 2.0.5
django-debug-toolbar 1.9.1 py_0 conda-forge
django-filter 1.1.0 py_0 conda-forge
django-import-export 1.0.0 py_0 conda-forge
djangorestframework 3.8.2 py_0 conda-forge
docutils 0.14 py35_0 conda-forge
dodgy 0.1.9 py35_0 conda-forge
et_xmlfile 1.0.1 py35_0 conda-forge
flake8 3.5.0 py35_0 conda-forge
flake8-polyfill 1.0.2 py_0 conda-forge
frosted 1.4.1 py35_0 conda-forge
idna 2.6 py35_1 conda-forge
isort 4.3.4 py35_0 conda-forge
jdcal 1.4 py35_0 conda-forge
lazy-object-proxy 1.3.1 py35_0 conda-forge
logilab-common 1.2.2 py35_0 conda-forge
mccabe 0.6.1 py35_0 conda-forge
odfpy 1.3.6 py_0 conda-forge
openpyxl 2.5.3 py35_0 conda-forge
openssl 1.0.2o vc14_0 [vc14] conda-forge
pep8 1.7.1 py_0 conda-forge
pep8-naming 0.5.0 py_0 conda-forge
pies 2.6.7 py35_0 conda-forge
pip 9.0.3 py35_0 conda-forge
prospector 0.12.2 py35_0 conda-forge
pycodestyle 2.3.1 py35_0 conda-forge
pycparser 2.18 py35_0 conda-forge
pydocstyle 2.1.1 py35_0 conda-forge
pyflakes 1.6.0 py35_0 conda-forge
pylint 1.8.4 py35_0 conda-forge
pylint-celery 0.3 py35_0 conda-forge
pylint-common 0.2.5 py35_0 conda-forge
pylint-django 0.11 py35_0 conda-forge
pylint-flask 0.5 py35_0 conda-forge
pylint-plugin-utils 0.2.6 py35_0 conda-forge
pyopenssl 17.5.0 py35_1 conda-forge
pyroma 2.0.2 py35_0 conda-forge
pysocks 1.6.8 py35_1 conda-forge
python 3.5.5 1 conda-forge
pytz 2018.4 py_0 conda-forge
pyyaml 3.12 py35_1 conda-forge
requests 2.18.4 py35_1 conda-forge
requirements-detector 0.5.2 py35_0 conda-forge
rollbar 0.13.17 py_0 conda-forge
setoptconf 0.2.0 py35_1 conda-forge
setuptools 39.1.0 py35_0 conda-forge
six 1.11.0 py35_1 conda-forge
snowballstemmer 1.2.1 py35_0 conda-forge
sqlparse 0.2.4 py_0 conda-forge
tablib 0.11.5 py35_0 conda-forge
unicodecsv 0.14.1 py35_0 conda-forge
urllib3 1.22 py35_0 conda-forge
vs2015_runtime 14.0.25420 0 conda-forge
vulture 0.26 py_0 conda-forge
wheel 0.31.0 py35_0 conda-forge
win_inet_pton 1.0.1 py35_1 conda-forge
wincertstore 0.2 py35_0 conda-forge
wrapt 1.10.11 py35_0 conda-forge
xlrd 1.1.0 py_2 conda-forge
xlwt 1.3.0 py35_0 conda-forge
yaml 0.1.7 vc14_0 [vc14] conda-forge

</p></details>

PS, I will be creating a new environment, and if i still can't pip install, I'll be doing a fresh install again, I do kinda need to use some packages right now that I can't get with conda

@kalefranz
Copy link
Contributor

After you update to conda 4.6.0a2, close your Anaconda Prompt shell, and then reopen it again. Does conda activate work as expected after that?

@MassiveAtoms
Copy link
Author

Still having pip problems, so I guess I'll do that fresh install.
Anything specific you want me to do and or collect, besides closing the shell and reopening after upgrading?

@kalefranz
Copy link
Contributor

I’m guessing you’re choosing the “system install” / “install for all users” vs just the “for me only” install, right? If you’ve been doing the first, and you run into problems again, try a fresh install but this time do the “for me only” type. (I don’t remember off the top of my head what the exact names are for the options.)

@kalefranz
Copy link
Contributor

Really appreciate your patience and willingness to go back-and-forth here too. You’re actually the first person I’m interacting with who is using a 4.6 alpha on Windows. I do think it’s for the most part pretty solid. But especially on Windows there could be a few hiccups for conditions outside of what I’ve tested so far.

@MassiveAtoms
Copy link
Author

MassiveAtoms commented May 5, 2018

I'm not sure what the option I selected when installing it for the first time, it probably was installed for all users. The other times I installed it today I selected to only install it for the current user.

And it's nothing, you and your team create this wonderful tool I use pretty much every day, and I like to think I'm contributing somewhat by trying to help with finding bugs 😄 I actually do want to contribute more, but I don't think I'm good enough at anything to help with actual development.

Ok, this time, I did some things different.
I after uninstalling and restarting, I uninstalled python at C:\Program Files (x86)\ (does conda install another one there? Because I can't actually remember using a standalone python installer on this OS, and when I do install it , it's usually at C;/python or some user directory, to prevent problems with UAC and the space in the path) and removed system and user variables of conda and python(which did not go away automatically after uninstalling). I then Installed anaconda.

This seems to have fixed the pip problem 😄

The problem of the shell command configuration is still there

C:\Users\sagar>conda activate testenv3

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If using 'conda activate' from a batch script, change your
invocation to 'CALL conda.bat activate'.

To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - cmd.exe
  - fish
  - tcsh
  - xonsh
  - zsh

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init'.

conda init


C:\Users\sagar>conda init --dry-run
no change     C:\Users\sagar\Anaconda3\Scripts\conda.exe
no change     C:\Users\sagar\Anaconda3\Scripts\conda-env.exe
no change     C:\Users\sagar\Anaconda3\Scripts\conda-script.py
no change     C:\Users\sagar\Anaconda3\Scripts\conda-env-script.py
no change     C:\Users\sagar\Anaconda3\condacmd\conda.bat
no change     C:\Users\sagar\Anaconda3\condacmd\_conda_activate.bat
no change     C:\Users\sagar\Anaconda3\condacmd\conda_auto_activate.bat
no change     C:\Users\sagar\Anaconda3\condacmd\conda_hook.bat
no change     C:\Users\sagar\Anaconda3\Scripts\activate.bat
no change     C:\Users\sagar\Anaconda3\condacmd\activate.bat
no change     C:\Users\sagar\Anaconda3\condacmd\deactivate.bat
modified      C:\Users\sagar\Anaconda3\Scripts\activate
modified      C:\Users\sagar\Anaconda3\Scripts\deactivate
modified      C:\Users\sagar\Anaconda3\etc\profile.d\conda.sh
modified      C:\Users\sagar\Anaconda3\etc\fish\conf.d\conda.fish
modified      C:\Users\sagar\Anaconda3\Lib\site-packages\xonsh\conda.xsh
modified      C:\Users\sagar\Anaconda3\etc\profile.d\conda.csh
needs sudo    HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
modified      C:\Users\sagar\Anaconda3\condacmd\Anaconda Prompt.lnk
modified      C:\Users\sagar\Desktop\Anaconda Prompt.lnk

==> For changes to take effect, close and re-open your current shell. <==

Operation failed.

C:\Users\sagar>conda init cmd.exe --dry-run
no change     C:\Users\sagar\Anaconda3\Scripts\conda.exe
no change     C:\Users\sagar\Anaconda3\Scripts\conda-env.exe
no change     C:\Users\sagar\Anaconda3\Scripts\conda-script.py
no change     C:\Users\sagar\Anaconda3\Scripts\conda-env-script.py
no change     C:\Users\sagar\Anaconda3\condacmd\conda.bat
no change     C:\Users\sagar\Anaconda3\condacmd\_conda_activate.bat
no change     C:\Users\sagar\Anaconda3\condacmd\conda_auto_activate.bat
no change     C:\Users\sagar\Anaconda3\condacmd\conda_hook.bat
no change     C:\Users\sagar\Anaconda3\Scripts\activate.bat
no change     C:\Users\sagar\Anaconda3\condacmd\activate.bat
no change     C:\Users\sagar\Anaconda3\condacmd\deactivate.bat
modified      C:\Users\sagar\Anaconda3\Scripts\activate
modified      C:\Users\sagar\Anaconda3\Scripts\deactivate
modified      C:\Users\sagar\Anaconda3\etc\profile.d\conda.sh
modified      C:\Users\sagar\Anaconda3\etc\fish\conf.d\conda.fish
modified      C:\Users\sagar\Anaconda3\Lib\site-packages\xonsh\conda.xsh
modified      C:\Users\sagar\Anaconda3\etc\profile.d\conda.csh
needs sudo    HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
modified      C:\Users\sagar\Anaconda3\condacmd\Anaconda Prompt.lnk
modified      C:\Users\sagar\Desktop\Anaconda Prompt.lnk

==> For changes to take effect, close and re-open your current shell. <==

Operation failed.

C:\Users\sagar>conda init cmd.exe

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "C:\Users\sagar\Anaconda3\lib\site-packages\conda\exceptions.py", line 875, in __call__
        return func(*args, **kwargs)
      File "C:\Users\sagar\Anaconda3\lib\site-packages\conda\cli\main.py", line 83, in _main
        exit_code = do_call(args, p)
      File "C:\Users\sagar\Anaconda3\lib\site-packages\conda\cli\conda_argparse.py", line 97, in do_call
        exit_code = getattr(module, func_name)(args, parser)
      File "C:\Users\sagar\Anaconda3\lib\site-packages\conda\cli\main_init.py", line 51, in execute
        anaconda_prompt)
      File "C:\Users\sagar\Anaconda3\lib\site-packages\conda\core\initialize.py", line 70, in initialize
        run_plan_elevated(plan2)
      File "C:\Users\sagar\Anaconda3\lib\site-packages\conda\core\initialize.py", line 487, in run_plan_elevated
        assert rc == 0
    AssertionError

`$ C:\Users\sagar\Anaconda3\Scripts\conda-script.py init cmd.exe`

  environment variables:
                 CIO_TEST=<not set>
                    CONDA=C:\Users\sagar\Anaconda3\Scripts;C:\Users\sagar\\Anaconda3;
               CONDA_ROOT=C:\Users\sagar\Anaconda3
                 HOMEPATH=\Users\sagar
                     PATH=C:\Program Files (x86)\Python36-32\Scripts\;C:\Program Files (x86)\Pyt
                          hon36-32\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\W
                          indows\System32\WindowsPowerShell\v1.0\;C:\Program
                          Files\Calibre2\;C:\Program Files\Git\cmd;C:\ProgramData\chocolatey\bin
                          ;C:\Users\sagar\Anaconda3;C:\Users\sagar\Anaconda3\Library\mingw-w64\b
                          in;C:\Users\sagar\Anaconda3\Library\usr\bin;C:\Users\sagar\Anaconda3\L
                          ibrary\bin;C:\Users\sagar\Anaconda3\Scripts;C:\Users\sagar\Miniconda3;
                          C:\Users\sagar\Miniconda3\Library\mingw-w64\bin;C:\Users\sagar\Minicon
                          da3\Library\usr\bin;C:\Users\sagar\Miniconda3\Library\bin;C:\Users\sag
                          ar\Miniconda3\Scripts;%cd%;C:\Program Files\Microsoft VS
                          Code\bin;C:\Program Files (x86)\Nmap
             PSMODULEPATH=C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\Windows
                          PowerShell\v1.0\Modules
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>

     active environment : None
       user config file : C:\Users\sagar\.condarc
 populated config files : C:\Users\sagar\.condarc
          conda version : 4.6.0a2
    conda-build version : 3.4.1
         python version : 3.6.4.final.0
       base environment : C:\Users\sagar\Anaconda3  (writable)
           channel URLs : https://conda.anaconda.org/auto/win-64
                          https://conda.anaconda.org/auto/noarch
                          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/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\sagar\Anaconda3\pkgs
                          C:\Users\sagar\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\sagar\Anaconda3\envs
                          C:\Users\sagar\AppData\Local\conda\conda\envs
                          C:\Users\sagar\.conda\envs
               platform : win-64
             user-agent : conda/4.6.0a2 requests/2.18.4 CPython/3.6.4 Windows/10 Windows/10.0.16299
          administrator : False
             netrc file : None
           offline mode : False


An unexpected error has occurred. Conda has prepared the above report.
If submitted, this report will be used by core maintainers to improve
future releases of conda.
Would you like conda to send this report to the core maintainers?
[y/N]: y
Upload successful.

Thank you for helping to improve conda.
Opt-in to always sending reports (and not see this message again)
by running

    $ conda config --set report_errors true


C:\Users\sagar>

Should I try running conda init cmd.exe from an elevated command line prompt?

@MassiveAtoms
Copy link
Author

MassiveAtoms commented May 7, 2018

AHA!
I spoke prematurely about the pip problem, I have encountered it again and found out the root cause. It is completely unrelated to conda.

Of the envs that have given me problems, the python.exe was missing from the folder

Microsoft Windows [Version 10.0.16299.371]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\sagar>cd C:\Users\sagar\Anaconda3\envs\cheminv

C:\Users\sagar\Anaconda3\envs\cheminv>dir
 Volume in drive C has no label.
 Volume Serial Number is 1222-5268

 Directory of C:\Users\sagar\Anaconda3\envs\cheminv
...snip
03/28/2018  06:19 AM            12,763 LICENSE_PYTHON.txt
06/10/2016  02:53 AM           633,152 msvcp140.dll
04/15/2018  02:35 PM           508,416 openssl.exe
04/06/2018  01:17 PM           413,696 python.pdb
04/06/2018  01:14 PM            51,200 python3.dll
04/06/2018  01:14 PM         4,166,656 python36.dll
04/06/2018  01:14 PM        10,227,712 python36.pdb
04/06/2018  01:17 PM            92,160 pythonw.exe
04/06/2018  01:17 PM           413,696 pythonw.pdb
... snip
C:\Users\sagar\Anaconda3\envs\cheminv> cd ../chemistry
C:\Users\sagar\Anaconda3\envs\chemistry>dir
 Volume in drive C has no label.
 Volume Serial Number is 1222-5268

 Directory of C:\Users\sagar\Anaconda3\envs\chemistry

...
02/04/2018  08:40 PM            12,763 LICENSE_PYTHON.txt
06/10/2016  02:53 AM           633,152 msvcp140.dll
04/15/2018  02:35 PM           508,416 openssl.exe
04/06/2018  01:06 PM           413,696 python.pdb
04/06/2018  01:04 PM            50,688 python3.dll
04/06/2018  01:04 PM         3,953,664 python35.dll
04/06/2018  01:04 PM         9,654,272 python35.pdb
04/06/2018  01:06 PM            35,328 pythonw.exe
04/06/2018  01:06 PM           413,696 pythonw.pdb
...

Then I made a list of everything I installed in the last month and which could delete files without me noticing.
Found the culprit.
image

I will be removing avast, do a fresh install of conda and see if that maybe also fixes the conda init problem.
I feel so conflicted now.
Awesome because I found the problem, and super stupid that I never thought to check that.

@MassiveAtoms
Copy link
Author

The AssertionError is still there when doing conda init cmd.exe, both on normal shell and an elevated one.

@github-actions
Copy link

Hi there, thank you for your contribution to Conda!

This issue has been automatically locked since it has not had recent activity after it was closed.

Please open a new issue if needed.

@github-actions github-actions bot added the locked [bot] locked due to inactivity label Sep 11, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked [bot] locked due to inactivity
Projects
None yet
Development

No branches or pull requests

2 participants