0

I have (almost) exactly the same question as this resolved question:

How to solve the issue of the conflict of anaconda and virtualenv?

..but my problem is the inverse. Namely, I had been working with conda environments fine before (for science projects), but when developing web projects I installed virtualenv. Since then, my conda environments are unreachable with the source command.

Here are my conda envs:

| => conda info --envs
# conda environments:
#
bunny                    /Users/.../anaconda/envs/bunny
root                  *  /Users/.../anaconda

The answer in the posted question, says I should change my current Anaconda path in bash_profile from :

export PATH=$HOME/anaconda/bin:$PATH

to:

export PATH=$PATH:$HOME/anaconda/bin

So, by changing this I thought running this command to the anaconda envs folder would work:

source /Users/.../anaconda/envs/bunny/bin/activate

The result is the virtualenv (env) gets activated, even if I am not on the directory where I installed it, which is:

/Users/./././WebDevelopment/DeployedProjects/./env

So I guess that the virtrualenv "source" command is masking the conda "source" command and works even if no absolute path is given:

| => source activate
(env) _______________________________________
| ~ @ Pablos-MBP 
| => 

Also on my bash_profile I have no path to virtualenv (like I do for anaconda)

How can I "create an alias to the virtualenv that calls it with an absolute path to the activate script" instead of calling it every time I use "source activate"?

Any help with this much appreciated!!

Best,

Pablo

PS. For reference, this answer also did not do the trick: Conda virtual environment not changing...

pablo-az
  • 437
  • 5
  • 15
  • `source` is a shell command, unrelated to virtualenv and anaconda.. – thebjorn Mar 08 '18 at 07:54
  • Thanks for the note @thebjorn . Not really sure what was causing the problem, but a simple update of conda did the trick: | => conda update conda After the update, my old virtualenv is now not accessible as I feared, but I created a new conda env with the requirements for my web development projects and all is working. I can deploy as per usual via conda and now also access my old conda envs. – pablo-az Mar 19 '18 at 04:23

1 Answers1

0

In case it is of help to others, for completion, I will outline the steps that I took.

After re-installing Anaconda and losing access to my previous virtualenv for web development, I abandoned virtualenv and moved my web development work to my Conda environments. Basically, I needed to (re)source the necessary paths.

My steps were the following:

Note: the "..." in paths are my username on MacOS.

  1. Create a new conda environment called "webdev", having python=2
  2. Downloaded the google-cloud-sdk and moved (manually) the entire folder to the "webdev" bin folder like:

    /Users/.../anaconda/envs/webdev/bin/google-cloud-sdk
    
  3. cd to that folder and run:

    ./install.sh
    
  4. Make sure PATHs in nano .bash_profile are linked. On terminal:

    $ cd
    
    $ nano .bash_profile
    
  5. Enter the following paths (first one should be there from Anaconda):

    export PATH=$HOME/anaconda/bin:$PATH
    
    export PATH=/Users/.../anaconda/envs/webdev/bin/google-cloud-sdk/completion.bash.inc:$PATH
    export PATH=/Users/.../anaconda/envs/webdev/bin/google-cloud-sdk/path.bash.inc:$PATH
    export PATH=/Users/.../anaconda/envs/webdev/bin/google-cloud-sdk/bin:$PATH
    
  6. Re-start the terminal. Enter the two commands in the terminal:

    source /Users/.../anaconda/envs/webdev/bin/google-cloud-sdk/completion.bash.inc
    
    source /Users/.../anaconda/envs/webdev/bin/google-cloud-sdk/path.bash.inc
    

After that this command should work:

 dev_appserver.py ./ 
pablo-az
  • 437
  • 5
  • 15