I am trying to re-enter my conda environment but I am having trouble doing so as when I type conda activate (evironment name) or source activate (environment name) both return the error 'Could not find conda environment.' This is very strange as when I type conda info --envs, I get this:
# conda environments:
#
base * /Users/(my name)/anaconda3
/anaconda3/envs/(environment name)
Names and Prefixes
For a Conda environment to have a name it must be installed in one of the envs_dirs directories (see conda config --show envs_dirs). Creating an environment outside of one of those forfeits its "name-ability". Instead, one must use the path (called its prefix) to activate it, e.g.,
conda activate /anaconda3/envs/my_env
Other commands will require one to use the --prefix|-p flag to specify the environment. See the documentation on "Specifying the location for an environment".
Adding Other Env Locations
If one plans to frequently install in a different location than the default, then there is an option to add directories to the envs_dirs configuration variable. In this specific case, this would be
conda config --append envs_dirs /anaconda3/envs
Note that whatever directory one specifies in this command will become the de facto default for future installs using the --name|-n flag. If one still wants to keep the standard default (/Users/<user>/anaconda3/envs), then they should follow the above with
conda config --prepend envs_dirs /Users/<user>/anaconda3/envs
That is, this will let one pick up the "names" of the environments installed in /anaconda3/envs, but calling conda create -n foo would still create it in /Users/(my name)/anaconda3/envs/foo.
For documentation, see: conda config --describe envs_dirs
Once upon a time I had a similar problem in Windows in Visual Studio Code terminal when I run activate C:\...\myEnvironmentFolder with the message Could not find conda environment: C:... The following command helped me:
source C:/myPath/Anaconda3/etc/profile.d/conda.sh
Then running activate C:\...\myEnvironmentFolder gave the desired effect
If you have the problem like this in cmd console, then, probably, you forgot to set the path in
Control panel -> System -> Advanced system settings -> User / System variables -> Path -> Edit -> New ->
and add
C:\ProgramData\Anaconda3\Scripts
C:\ProgramData\Anaconda3
C:\ProgramData\Anaconda3\Library\bin
You can try using a different method to create a virtual environment, Open CMD and type pip install virtualenvwrapper-win and hit enter this would be your step 1.
Step 2) mkvirtualenv
Related
I have an environment called envname, but I would like its packages to be available in the base environment. How can I do this without reinstalling each of them?
Word of Caution
Be very careful when tinkering with the base env. It's where the conda package lives and so if it breaks, the Conda installation will break. This is a very tedious situation to recover from, so I generally recommend against using the base env for anything other than running conda update -n base conda.
That said, one should only try the following for sharing between two non-base envs.
Copying (Linking) Packages Across Envs
One way would be to export an env, let's call it foo, out as a YAML:
conda env export -n foo > foo.yaml
And then ask the other env, let's call it bar, to attempt to install all the packages:
Warning: Conda will attempt the following command without requesting approval!
conda env update -n bar -f foo.yaml
Note that if the foo env has conflicting packages, they will all supersede whatever was in the bar env (if resolvable). To be cautious, you should probably do a diff first, to see what is going to get overwritten. E.g.,
conda env export -n bar > bar.yaml # this is also useful as backup
diff -u bar.yaml foo.yaml
A major thing to check for is the python version. They should match up to and including the minor version (e.g., 3.6.x and 3.6.y are okay; 3.6 and 3.7 are not).
To err on the side of caution, one should probably manually remove any packages from the YAML that would be reversions - however, this could lead to conflicts.
The deletions will not have an effect unless also using the --prune argument (essentially that would completely overwrite bar with foo).
Hopefully all these qualifications and warnings make the point: it could be a mess. It is usually better practice to thoughtfully design a fresh env from the start.
Unfortunately my base environment has become corrupt and I need to uninstall and reinstall anaconda to fix the issue (not ideal!) I was reading the documentation:
https://docs.anaconda.com/anaconda/install/uninstall/
I am unable to "conda install anaconda-clean" because of the issue with my base environment which leaves me with Option A:
"Open the Terminal.app or iTerm2 terminal application, and then remove
your entire Anaconda directory, which has a name such as anaconda2,
anaconda3, or ~/opt. Enter rm -rf ~/anaconda3 to remove the
directory."
-
"This will leave a few files behind, which for most users is just
fine."
What I want to check is that these few files that are left behind, are these going to create any issues when I reinstall anaconda.
The anaconda-clean function is basically a list of files to delete and an interactive for-loop. One can easily do the same thing manually.
Here is the list (which notably has not changed since 2016):
FILES = [
'.anaconda', '.astropy', '.continuum',
'.conda', '.condamanager', '.condarc',
'.enthought', '.idlerc', '.glue', '.ipynb_checkpoints', '.ipython',
'.jupyter', '.matplotlib', '.python-eggs',
'.spyder2', '.spyder2-py3', '.theano',
]
As always, back stuff up first.
(Opinionated) Advice
Since you're starting fresh, I strongly encourage installing Mambaforge (a Miniforge variant that includes Mamba in the base) and avoid installing anything but Conda infrastructure in the base env. If you need Anaconda, simply create an env with it, e.g.,
conda create -n foo anaconda
I am getting this error when I tried to run an example helloworld code I got onlie.
compile: version "go1.9" does not match go tool version "go1.9.1"
My computer has go1.9.1. What does the error mean and how can I fix this?
If you are installing using OSX homebrew you may need to set the $GOROOT in your .bashrc, .zshrc, etc:
export GOROOT=/usr/local/opt/go/libexec
I had the same error this morning when I updated from 1.9 -> 1.9.1 though according to several post the $GOROOT shouldn't have to be set and I had not set it until today. This may be a bug?
Edit: not a bug, for more details see answer below.
This is a mismatch between the GOROOT environment variable and the default path to your go command. One or the other needs to be changed; the one that needs to be changed depends on the specific setup on your computer. You could determine this by updating your Go to the latest version using your preferred method, running either which go (on Linux/macOS/BSD) or where go (on Windows), and then checking which of the files listed has the newer timestamp.
Linux/macOS/BSD
To change the GOROOT to match the default path of your go command, run type go and strip off the /bin/go part at the end to yield the directory path containing your Go installation. Then, add it to your .bashrc or other appropriate init file like this:
export GOROOT=/path/to/go-installation
To instead change the go command path to match your GOROOT, add this to the bottom of your init file:
export PATH="${GOROOT}/bin:${PATH}"
Windows
To change the GOROOT to match the default path of your go command, run where go take the first line of output, and strip off the \bin\go.exe part at the end. Then, go to "Edit the system environment variables" in Settings, click "Environment Variables...", find the "GOROOT" variable and edit to read the path you created earlier.
To instead change the go command path to match your GOROOT, first save the output of echo %GOROOT%\bin. Then, go to "Edit the system environment variables" in Settings, click "Environment Variables...", and find the
find the "Path" row in the bottom pane, click New, put in the path you created earlier, and finally click Move Up until it's at the top.
All
You'll need to open up a new command prompt to see the effects.
in case you are using mac with homebrew, just run:
brew cleanup
to clean all the legacy package, this fixed my problem.
In mac OS , if you downloaded and installed go package without brew, running brew update commands will cause this problem to occur
for fix this problem you can do :
brew uninstall --ignore-dependencies go
uninstalling go from brew will fix problem
This error happens when you forgot to delete previous golang install ... just delete its directory ... so identify go install location ... on linux issue
type go
typical output is
go is hashed (/usr/local/go/bin/go)
so just remove its grandparent directory ( go install dir not just the go binary )
sudo rm -rf /usr/local/go # NOTE this is not /usr/local/go/bin/go
now just install go and you'll be fine
For M1 Mac, the following steps helped me!
Check for which go from VSCode Terminal and check from system terminal.
from vscode terminal
user#mac % which go
/usr/local/go/bin/go
from my mac terminal
user#mac % which go
/opt/homebrew/bin/go
Whichever corresponds to the GOROOT shown go env, keep it and delete the other one
user#mac % go env GOROOT
/usr/local/go
in this case
rm -rf /opt/homebrew/bin/go
close and reload the vscode and terminal
For Windows delete the GOROOT System variables in the Enviroment Variables and restart the PC.
if you use VsCode, you just add this in setting.json.
"go.goroot": "/usr/local/Cellar/go/1.x.x/libexec",
For me, it's caused by GOROOT env, using gotip before, change to brew version.
# curret go env
cat "$(go env GOENV)"
# make sure this is correct
go env GOROOT
# unset GOROOT if setted before
go env -u GOROOT
you may also want to set a proper GOROOT to match the go version.
In my case, I had a scripts that look like this:
[[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm"
Hanging around in my .bashrc/.zshrc file from a previous installation of go / trying to use gvm.
Removing this and restarting terminal solved it for me.
I had the same issue when I used getgo to update my Go version from 1.19 to 1.20. In my case, getgo created a .bash_profile and set its own export path w/c is not consistent with what's in my .bashrc.
#my .bash_profile;
export PATH=$PATH:/home/user/.go/bin
export PATH=$PATH:/home/user/go/bin
#my .bashrc;
export GOROOT=/usr/local/go/
export GOPATH=$HOME/go
export PATH=$PATH:$/home/user/go/bin:$GOROOT/bin:$PATH
SOLUTION:
I just replaced my export PATH in bashrc w/
export PATH=$PATH:$/home/user/.go/bin:$GOROOT/bin:$PATH
<Note the '.go' change w/c is now consistent to what's in my .bash_profile>.
So whether source is ~/.bashrc or ~/.bash_profile, it will always point to the same path for Go. Hope this helps. I'm also new to Go and Ubuntu. I know how painful it is to get these variables right on your own.
Took a simple approach(Linux), I had different versions of Go installed in my system.
$ whereis go
helped me to find the available go runnables, removed all, installed a fresh one and ensured to create a link for this new Go runnable in one of the $PATH folder to ensure below gives the correct version of what installed now.
$ go version
I realise I can create a new environment from a yml with conda env create -f environment.yml (from conda docs).
However in my case, I have an environment already setup with a ton of things installed and setup just the way I like and need it. Now I'd like to install a new package which has a bunch of dependencies. From what I can see there are no conflicts with my current env. Is it possible to somehow import this yml into my current environment? I couldn't find any info on this on the docs or the web (they all point back to creating a new env from the yml).
I realise I can export my current environment as a yml, do a merge with the new yml, and then create a new environment with the merged file, but that seems a bit convoluted for something which I think would be a relatively common request.
I was able to do an environment update like this by following the instructions here:
How to update an existing Conda environment with a .yml file
I did have to deactivate the environment to update the dependencies as per Dave's comment.
I'm trying to run Go in an interactive mode.
I want to use go-eval for that, I followed their README instructions:
I ran go get github.com/sbinet/go-eval/ successfully
I ran go-eval which resulted in -bash: go-eval: command not found
Some more information:
echo $PATH returns: /usr/local/go/bin:...
echo $GOPATH returns: $HOME/golang
running whereis go-eval returns no output
running go install go-eval returns:
can't load package: package go-eval: cannot find package "go-eval" in any of:
/usr/local/go/src/go-eval (from $GOROOT)
$HOME/golang/src/go-eval (from $GOPATH)
You'll need to add GOPATH/bin to PATH.
PATH="$GOPATH/bin:$PATH"
Update [Go 1.8 and above]: GOPATH will default to $HOME/go. The above will not work if GOPATH is not explicitly set.
To set both, add this to your .profile file:
export GOPATH="$HOME/go"
PATH="$GOPATH/bin:$PATH"
Ran into this issue while using export PATH="~/go/bin:$PATH".
Seems the ~ was causing problems and changing to the full path worked.
Try something like this instead, which won't use a tilde:
export PATH="$HOME/go/bin:$PATH"
Is the binary go-eval in $GOPATH/bin? Are you running the command with $GOPATH/bin/ as your working directory? If not, thats likely the problem.
go get & go install installs go binaries (if any) in $GOPATH/bin
Check $GOPATH/bin for the go-eval binary. If its there, try running it from $GOPATH/bin with ./go-eval. If that works, you're good.
In future, if you wish to run go binaries found in $GOPATH/bin from anywhere in your shell, add the following to your .bashrc or profile:
export PATH=$PATH:$GOPATH/bin
Then restart your terminal or run . ~/.bashrc or . /etc/profile
When running go install go-eval I get:
can't load package: package go-eval: cannot find package "go-eval" in any of:
/usr/local/go/src/go-eval (from $GOROOT)
$HOME/golang/src/go-eval (from $GOPATH)
You get the above error because go-eval is not in $HOME/golang/src/go-eval. Running go get github.com/sbinet/go-eval/ will download the source to $GOPATH/src/github/sbinet/go-eval/. If you want to run go install go-eval, you have to specify the package name relevant to its position in the directory hierarchy in $GOPATH/src.
e.g.
go install github/sbinet/go-eval
I'd like to add this in addition to the answers given.
As a helpful tip, uou can always test your commands with the which command.
Such as: which go
If the command is not found, you know you have a PATH problem you need to address first.
Then you can focus on finding the command with the find command.
Such as: find / -name "go" -print 2>/dev/null
The first slash is the directory to start the search, the argument to the -name is the command you're looking for and the -print gets a good results look. the 2>/dev/null sends results of directories that are not accessible to neverland (null) so that you do not need to see a bunch of errors.
Using this process helps you quickly find the command in question and then you can add it to your PATH env variable and it becomes accessible as stated in the other answers.
All above answers are self explaining. Over and above those I would like to add that by default you can access only those commands from terminal without path to binary whose bin folder is added to the environment variable, be it linux, mac or windows.
Else you will have to specify the path to bin folder of that software followed by the binary name. For instance in your case <path_to_bin_folder>/go-eval.
This is the most common reason that you are not able to execute that command directly from the command line. Please remember this and try this before searching for answers online because this will most probably solve your issue. All you have to know is the installation path.
So, write the following into the rc or profile file for your terminal and save, example for zsh it is ~/.zshrc, for bash it is ~/.bash_profile or ~/.bash_rc.
export GOPATH="$HOME/go"
export PATH=$PATH:$GOPATH/bin
Now although the file is saved but the changes will not reflect immediately. You have to source the profile file as mentioned above. For this type source ~/.zshrc. You should now be able to run the command directly from command line now. Even if the problem still persists try quit the terminal session and logging off and then logging in.
In case you want to add path to bin folder for other packages, you can append it to the $PATH environment variable using :. So for example if you want to add path to java binary as well, then just do
export PATH=$PATH:$JAVA_HOME/bin
Also it is a good practice to define the path to root folder of a package in its separate environment variable(example $GOPATH="$HOME/go"). In case if the installation path changes in future then you'll just have to update the environment variable related to that binary (example just update, $GOPATH="newpath") and your command will work as previously, since the change in $GOPATH will reflect in $PATH.
add those line in to ~/.zshrc
export GOPATH="$HOME/go"
export PATH=$PATH:$GOPATH/bin
run source ~/.zshrc