Failed to start a TensorBoard session in vscode due to the following error: - tensorboard

To launch tensorboard in vscode, I did the following steps:
select a python interpreter path
choose Python:Launch TensorBoard
and then I get this error:
We failed to start a TensorBoard session due to the following error: Command failed: conda activate ldl && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python /home/cxy/.vscode-server/extensions/ms-python.python-2022.18.2/pythonFiles/printEnvVariables.py
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If your shell is Bash or a Bourne variant, enable conda for the current user with
$ echo ". /home/cxy/anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc
or, for all users, enable conda with
$ sudo ln -s /home/cxy/anaconda3/etc/profile.d/conda.sh /etc/profile.d/conda.sh
The options above will permanently enable the 'conda' command, but they do NOT
put conda's base (root) environment on PATH. To do so, run
$ conda activate
in your terminal, or to put the base environment on PATH permanently, run
$ echo "conda activate" >> ~/.bashrc
Previous to conda 4.4, the recommended way to activate conda was to modify PATH in
your ~/.bashrc file. You should manually remove the line that looks like
export PATH="/home/cxy/anaconda3/bin:$PATH"
^^^ The above line should NO LONGER be in your ~/.bashrc file! ^^^
I have tried the suggested command, which is
echo ". /home/cxy/anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc
but it doesn't work, I still get the same error.
How can I solve this problem? Is there any suggestion? thanks in advance!!!

I have solved this problem!!!
Basically, it is caused by the latest version of Python and Pylance extension in vscode, all we have to do is simply downgrade the two extensiona and make sure vscode won't update them automatically.
So, do the following:
Downgrade Python extension and Pylance extension to eariler version, like v2021.10.xx and v2021.10.0 respectively.
Close the extension auto update in vscode, to ensure the downgradion in step1 works after restarting vscode.
Specifically, openSettings and search for the keyword update, do the following:
2.1. beneath the Update: Mode,select None instead of default
2.2. beneath the Extensions: Auto Update, select None instead of All extensions
After I did the above steps, the problem just disappeared. I can then launch tensorboard by shift+cmd+P and select Python:Launch TensorBoard.

Related

kubectl plugin tab auto complete not working with zsh

After installing kubernetes-cli via homebrew in a mac with zsh, the kubernetes auto complete is not working completely or in full. Only the first tab works and not the second tab onwards. Example, if I type kubectl [TAB], it displays the sub commands for kubectl, and now if I select a sub command and press [TAB], eg kubectl get [TAB], it freezes for a lot of time and nothing happens there after.
I tried the following ways
Installed kubectl-cli via home brew
enabled zsh plugin
added the below code as well
source <(kubectl completion zsh)
autoload -Uz compinit
compinit
Finally this worked after referring to https://kubernetes.io/docs/reference/kubectl/cheatsheet/#zsh
echo '[[ $commands[kubectl] ]] && source <(kubectl completion zsh)' >> ~/.zshrc # add autocomplete permanently to your zsh shell
The below did not work
https://kubernetes.io/docs/tasks/tools/included/optional-kubectl-configs-zsh/

Switch between anaconda and miniconda (miniforge)

I have installed conda using miniforge. Since my mac has a m1 chip, i had to install conda using Miniforge3-MacOSX-arm64.sh, inorder to get tensorflow working. unfortunately this version (minforge/minconda arm64) doesn't have python2 for some reason. As I require python2 for another project (doesnot require tensorflow) I have decided to install anaconda3.
But now I am unaware how to switch between the two conda versions (anaconda3 and miniconda/miniforge3).
For example when I enter activate conda in the terminal, it activates the base environment of the miniforge version.
How do I activate base environment of the anaconda version. So that I can create python2 environment there (anaconda3).
According to this post, one solution is to change the content of your .zshrc file, save your changes, close and reopen your terminal. I tested on a MacBook Pro M1 where Miniforge3 and Anaconda3 are currently installed and it works. In the following, just replace --PATH-- with the path of the requested environment management system. For example, I replace --PATH-- with opt/anaconda3 for Anaconda3 and miniforge3 for .. Miniforge3.
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/username/--PATH--/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/Users/username/--PATH--/etc/profile.d/conda.sh" ]; then
. "/Users/username/--PATH--/etc/profile.d/conda.sh"
else
export PATH="/Users/username/--PATH--/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
A quick fix for switching between environments is to pick out the path you get from the output of conda env list. Here is what I get from both miniforge and miniconda:
(base) user#machine script % conda env list
# conda environments:
#
base * /Users/user/miniforge3
nmgp /Users/user/miniforge3/envs/nmgp
scphere /Users/user/miniforge3/envs/scphere
/opt/miniconda3
/opt/miniconda3/envs/gpcounts
/opt/miniconda3/envs/gpy
/opt/miniconda3/envs/test
/opt/miniconda3/envs/nmgp
/opt/miniconda3/envs/scphere
/opt/miniconda3/envs/ssdgp
To activate the miniforge environments you can use the name directly:
conda activate nmgp
To activate a miniconda environment you can use the absolute path:
conda activate /opt/miniconda3/envs/nmgp

Create PDF reports using R Markdown (TinyTeX) in Snakemake using Conda

I am currently having problems using TinyTeX in a conda environment with Snakemake. I have to install TinyTeX installation files using the command tinytex::install_tinytex() before running the pipeline. This installs TinyTeX outside of the created environment (which isn't that big of a problem... but not preferred either) . The main problem is that every time I execute my Snakemake pipeline it will try to reinstall this installation which I don't want. Could anyone tell me what the easiest way is for me to check whether it's installed already? Should I be using the command Rscript -e \"tinytex:::is_tinytex()\" with an if-statement? And what is the best way to write that if-statement by calling Rscript -e in Snakemake? Or should I just write a boolean text-file on first run which specifies whether TinyTeX has been installed before?
It kinda sucks that the TinyTeX conda dependency doesn't work on its own without additional installation...
Snakemake rule (ignore input/output):
rule assembly_report_rmarkdown:
input:
rules.assembly_graph2image_bandage.output,
rules.assembly_assessment_quast.output,
rules.coverage_calculator_shortreads.output,
rules.coverage_calculator_longreads.output
output:
config["outdir"] + "Hybrid_assembly_report.pdf"
conda:
"envs/r-rmarkdown.yaml"
shell:
"""
cp report/RMarkdown/Hybrid_assembly_report.Rmd {config[outdir]}Hybrid_assembly_report.Rmd
Rscript -e \"tinytex::install_tinytex()\"
Rscript -e \"rmarkdown::render('{config[outdir]}Hybrid_assembly_report.Rmd')\"
rm -f {config[outdir]}Hybrid_assembly_report.Rmd {config[outdir]}Hybrid_assembly_report.tex
"""
Conda YAML:
name: r-rmarkdown
channels:
- conda-forge
- bioconda
dependencies:
- r-base=4.0.3
- r-rmarkdown=2.5
- r-tinytex=0.27
Thanks in advance.
I think I've solved the issue. Instead of calling Rscript -e, I have put the following if-statement in the setup chunk in R Markdown (Which runs before running any other code if i'm correct). I then proceeded to uninstall TinyTeX to see whether it will install for once only which it did.
knitr::opts_chunk$set(echo = TRUE)
library(knitr)
if (!tinytex:::is_tinytex()){
tinytex::install_tinytex()
}

CentOS 7 sudo >> -E: command not found

I'm working on CentOS 7 and regular sudo commands (e.g. sudo yum update, etc.) are working fine. However, one of my sudo commands require to preserve the environment variables, so I used:
sudo -E ./build/unit-tests
and I get this error:
/var/tmp/sclyZMkcN: line 8: -E: command not found
It appears sudo is not recognizing the -E command on CentOS 7. What can I do in this case? Any alternatives or possible fix?
I've recently come across exactly the same problem. I tried to execute a script with sudo -E, which caused the above-mentioned -E: command not found error.
The reason turned out to be Red Hat Developer Toolset providing a broken sudo. A solution is to use the full sudo system path to make sure a good one is used, i.e.
/usr/bin/sudo -E ./some_script.sh
I you know which variables to preserve, you can use env to pass them through the command line.
sudo env foo="$foo" bar="$bar" ./build/unit-tests

Fabric and virtualenv working on Ubuntu but not on Solaris

I have a project that runs on Ubuntu and Solaris. Fabric works fine with Ubuntu but does not on Solaris. If I try something inside a virtualenv it fails with workon: command not found.
This is how my fabfile.py looks like:
with prefix('workon %s' % env.virtualenv):
sudo('manage.py collectstatic --noinput')
I put those lines in .profile on both platforms:
export WORKON_HOME=$HOME/.virtualenvs
source /path/to/virtualenvwrapper.sh
That's all I've done. Why does Ubuntu work but Solaris doesn't? Any ideas?
It's Virtualenvwrapper that's failing, not Fabric or Virtualenv. Try using Virtualenv directly with:
with prefix('source path/to/virtualenv/bin/activate'):
sudo('manage.py collectstatic --noinput')
EDIT:
to try to fix virtualenvwrapper, try wrapping your code in the following, and see if it solves the original error.
with prefix('source path/to/virtualenvwrapper.sh'):
Consider where you have put the following?
export WORKON_HOME=/opt/virtual_envs
source /usr/local/bin/virtualenvwrapper.sh
According to man bash, the -l flag, that fabric issues, will cause the the following to happen
[bash] looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.
I had this bootstrap code in .bashrc, which wasn't being sourced by bash -l. I moved those two lines to .profile, and can now do the fabric lines below. (I don't have .bash_profile or .bash_login)
with cd('/www/code'):
with prefix('workon code'):
run('./manage.py validate')