Why did my terminal suddenly has darwin13 as host? How do I fix this? - terminal

I was trying to install Kaggle but then all of a u sudden I see:
#x86_64-apple-darwin13 on my terminal.
How do I switch this back? I was trying some solutions I found online but every time I run open ~.bash_profile it says:
zsh: no such user or named directory: .bash_profile

Every time turn on terminal, conda will be activated automatically.
Try the following command should work
conda config --set auto_activate_base false

Related

Miniconda: issue with shell configuration/initialization

I installed miniconda on our CentOS cluster and it all went fine. Then I asked miniconda to create a python 3.8 environment, and it went fine. However, when I try to activate the environment, I get the following error:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
I verified, and it's a bash environment. So I ran conda init bash and I got the following outputs:
no change /MyPath/miniconda3/condabin/conda
no change /MyPath/miniconda3/bin/conda
no change /MyPath/miniconda3/bin/conda-env
no change /MyPath/miniconda3/bin/activate
no change /MyPath/miniconda3/bin/deactivate
no change /MyPath/miniconda3/etc/profile.d/conda.sh
no change /MyPath/miniconda3/etc/fish/conf.d/conda.fish
no change /MyPath/miniconda3/shell/condabin/Conda.psm1
no change /MyPath/miniconda3/shell/condabin/conda-hook.ps1
no change /MyPath/miniconda3/lib/python3.9/site-packages/xontrib/conda.xsh
no change /MyPath/miniconda3/etc/profile.d/conda.csh
no change /home/users/me/.bashrc
No action taken.
So nothing happens. And when I try to activate the new environment, then I still get the first error.
Any idea how I can fix this?
[Solution] Thanks to the answer below, the issue was that despite testing that I was running/using a bash, I still have to run "bash" in the command line before activating model.
have you tried manually adding to ~/.bashrc?
add export PATH="/home/username/miniconda/bin:$PATH" in your bashrc file. make sure to replace /home/username/miniconda with your actual path now save the file, quit and reopen the terminal should work I guess.

Why is git bash behaving weird on PyCharm?

I am using PyCharm 2019.3.3 (Community Edition) on Windows 8. I wanted to integrate Git bash in the PyCharm terminal. I have set the shell path in the terminal application settings of PyCharm as
C:\Program Files\Git\bin\bash.exe
The problem occurs when I activate a venv virtual ennvironment, set up using
python -m venv env
by running
source env/Scripts/activate
I think env is active as I see two parenthesis, () and typing pip freeze displays all installed packages in env. But this is accompanied with an error message that displays in the terminal
bash: basename: command not found
This same message is logged after typing commands like ls, clear which doesn't work but pip freeze and pip --version work. And when I deactivate env, ls, clear and pip stopped working displaying the mentioned error message.
All this problems do not occur in the Git bash application for Windows irrespective of whether I am in env or global environment and all commands work properly. I know I can just use Git bash instead of the integrated terminal of PyCharm but just wanted an answer to this problem.
What seems to be the problem here? Am I setting up my shell path wrongly or is this problem specific to PyCharm?
I solved this issue by disabling "Activate Virtualenv" checkbox in File -> Settings -> Tools -> Terminal
Since, pycharm documents does not show any support for 'Git Bash', that is probably the reason for this weird behaviour.
Terminal Options in Pycharm

Updating Anaconda fails: Environment Not Writable Error

I'm trying to update Anaconda and its packages using conda update --name root conda, but it fails every time.
Error message : EnvironmentNotWritableError: The current user does not
have write permissions to the target environment. environment
location: C:\ProgramData\Anaconda3
Environment location: C:\ProgramData\Anaconda3. I replaced the root with base, still I get the same error.
Any help?
start your command prompt with run as administrator
If you face this issue in Linux, one of the common reasons can be that the folder "anaconda3" or "anaconda2" has root ownership. This prevents other users from writing into the folder.
This can be resolved by changing the ownership of the folder from root to "USER" by running the command:
sudo chown -R $USER:$USER anaconda3
or sudo chown -R $USER:$USER <path of anaconda 3/2 folder>
Note: How to figure out whether a folder has root ownership?
-- There will be a lock symbol on the top right corner of the respective folder.
Or right-click on the folder->properties and you will be able to see the owner details
The -R argument lets the $USER access all the folders and files within the folder anaconda3 or anaconda2 or any respective folder. It stands for "recursive".
On Windows, search for Anaconda PowerShell Prompt. Right click the program and select Run as administrator. In the command prompt, execute the following command:
conda update -n base -c defaults conda
Your Anaconda should now update without admin related errors.
Open this folder "C:\ProgramData\" and right-click on "\Anaconda3". go to properties -> security and check all the boxes for each user. This worked for me.
If you get this error under Linux when running conda using sudo, you might be suffering from bug #7267:
When logging in as non-root user via sudo, e.g. by:
sudo -u myuser -i
conda seems to assume that it is run as root and raises an error.
The only known workaround seems to be: Add the following line to your ~/.bashrc:
unset SUDO_UID SUDO_GID SUDO_USER
...or unset the ENV variables by running the line in a different way before running conda.
If you mistakenly installed anaconda/miniconda as root/via sudo this can also lead to the same error, then you might want to do the following:
sudo chown -R username /path/to/anaconda3
Tested with conda 4.6.14.
I had installed anaconda via the system installer on OS X in the past, which created a ~/.conda/environments.txt owned by root. Conda could not modify this file, hence the error.
To fix this issue, I changed the ownership of that directory and file to my username:
sudo chown -R $USER ~/.conda
On Windows in general, running command prompt with administrator works. But if you don't want to do that every time, specify Full control permissions of your user (or simply all users) on Anaconda3 directory. Be aware that specifying it for all users allows other users to install their own packages and modify the content.
I had the same issue and the base environment was in C:\ProgramData\Anaconda3. This is the case, when Anaconda is installed for all users.
As a solution, I re-installed Anaconda just for me and now the base environment is in \AppData\Local\Continuum\anaconda3. This now can be updated via conda update without admin privileges.
As an alternative, I would suggest looking at your conda config file.
Reason
Sometimes for creating a virtual env at a specified location other than the pre-defined path at ~/anaconda3/envs we append the conda config file using: conda config --append envs_dirs /path/to/envs where envs_dirs is a specified function in config file for allocating different paths where conda can find your virtual envs. Removing a recently added path in this config file may solve the problem.
Solution
$:> conda config --show envs_dirs
envs_dirs:
- /home/some_recent_path # remove this
- /home/.../anaconda3/envs
Note the value specifing a different directory other than the predefined location, and remove it using
$:> conda config --remove envs_dirs /home/some_recent_path
Now the config file envs_dirs is set to default location of envs. Try creating a new env now.
this line of code on your terminal, solves the problem
$ sudo chown -R $USER:$USER anaconda 3
WINDOWS:
I also got following error while (base) PS E:\Python> conda install ConfigParser
Verifying transaction: failed
EnvironmentNotWritableError: The current user does not have write permissions to the target environment.
environment location: C:\ProgramData\Anaconda3
My solution: Open Command prompt as administrator, then above command again and it worked.
C:\WINDOWS\system32>conda install ConfigParser
Collecting package metadata (current_repodata.json): done Solving environment: done
Package Plan
environment location: C:\ProgramData\Anaconda3
added / updated specs:
- configparser
The following NEW packages will be INSTALLED:
configparser pkgs/main/noarch::configparser-5.0.2-pyhd3eb1b0_0
Proceed ([y]/n)? y
Preparing transaction: done Verifying transaction: done Executing
transaction: done
I had the same problem. The cause for me was that when downloading Anaconda, I chose 'download for all users' instead of 'just for me'. I uninstalled it, re-installed it and corrected that. And I'm not getting this error anymore.
On Windows,
Create a new environment with
conda create --name py35 python=3.5
see conda cheat sheet
Activate this environment
activate py35
Now you don't need to have root access to your new environment.
As mentioned in a comment to the accepted answer, the default environment base requires administrative rights on Windows:
On Windows, if you're trying to install packages into the base
environment (which is installed to C:\ProgramData\Anaconda3), you'll
need admin access. If you first create an environment (which should
install in your user directory under .conda\envs) and activate it, you
no longer need admin right for that environment. Don't forget to
activate the env after creating it. – C.J. Jackson
In my case somehow CONDA_ENVS_PATH was removed, so I was having NotWritableError. So I fixed the error by specifying
CONDA_ENVS_PATH=~/my-envs:/opt/anaconda/envs
in the .bashrc file
I was also suffered by same problem. I resolved the problem by reinstalling anaconda(While installation at this time I selected "just for me" as user) and my problem was solved.Try the same
CONDA UPDATE - NO WRITE ACCESS PROBLEM ## FIXED##
SIMPLE SOLUTION:
Press the Windows+S combination button and type "cmd" into it.
Right click on the Command Prompt App result that shows up and click on "Run as administrator"
Now, in the black window that is open (i.e. your Command prompt), copy and paste the following to check for your version: conda --version
If you want the latest update, then update Conda by running the update command by pasting the following and clicking enter in the command prompt(black window):
conda update conda
If a newer version is available, it will prompt you for a yes/no to install the update. Type "yes" and then press Enter to update.
Deleting file .condarc (eg./root/.condarc) in the user's home directory before installation, resolved the issue.

How to activate a conda env automatically in VSC on windows using bash?

I've been trying all day to debug a code using Visual Studio Code without success. I have installed VSC on windows and I have installed bash (ubuntu) as well. I already put bash as a terminal default shell:
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\bash.exe"
The thing is when I run the debug, it tries to activate the env with activate myenv-name and I couldn't find how to change this instruction to source activate myenv-name.
Do you know how I can do this? any help will be appreciated. Thanks!
It's been a while since I asked this question and I got the answer finally. :)
It is simple we just have to create .bashrc file in our user folder there we can write whatever commands we need to run each time we start a terminal in vscode.
Here the command to activate a conda env:
source activate myenv_name
In case of bash: conda: command not found and you don't have admin permissions to change the paths use this command before source act...:
export PATH=$"/c/Users/UserName/AnacondaPath/Scripts":$PATH

Basic terminal commands not working after trying to install Composer

My mac terminal is completely dysfunctional! Every time I open terminal I get this message:
-bash: export: `/Applications/MAMP/bin/php/php5.5.10/bin/:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin': not a valid identifier
The problem came about a while ago, I believe I was attempting to install composer to work with MAMP.
Today I started a beginner tutorial on how to use the Terminal and almost every command does not work such as the basic mkdir , ls , and touch (to make folder, list items, and make a file respectively), (screenshot attached).
I have already tried deleting the ~/Library/Preferences/com.apple.Terminal.plist file. Your help is greatly appreciated.
I am working with Mac OS X 10.10.2
screenshot of terminal after making basic commands
It looks like you have an error in your .bash_profile or other startup script. Open it on terminal using vi ~/.bash_profile or some other editor of your choice and comment out that line, then type source .bash_profile to reload it.

Resources