The conda environment is created in linux called (L1) using
conda create --prefix /anaconda_env/personal/env1 python=3.6
I mount the conda environment in the linux called (L2). Then I activate the environment in the linux.
export PATH=$PATH:/opt/miniconda/bin
source activate /anaconda_env/personal/env1
Then I got this error:
/anaconda_env/miniconda/bin/conda: line 3: import: command not found
/anaconda_env/miniconda/bin/conda: line 6: syntax error near unexpected token sys.argv' /anaconda_env/miniconda/bin/conda: line 6:
if len(sys.argv) > 1 and sys.argv[1].startswith(βshell.β) and sys.path and sys.path[0] == ββ:β
When I check
conda --version
, the same error is shown.
I also tried using
conda activate /anaconda_env/personal/env1
But it also does not work. May I know how can I solve this issue?
Inside the miniconda/bin/conda, the script is as follow
#!/anaconda_env/miniconda/bin/python
-- coding: utf-8 --
import sys
Before any more imports, leave cwd out of sys.path for internal βconda shell.*β commands.
if len(sys.argv) > 1 and sys.argv[1].startswith(βshell.β) and sys.path and sys.path[0] == ββ:
# The standard first entry in sys.path is an empty string,
# and os.path.abspath(ββ) expands to os.getcwd().
del sys.path[0]
if name == βmainβ:
from conda.cli import main
sys.exit(main())
1 Like
dear 9.susan2.
thank you for posting.
The conda command, like pyenv, creates an environment alias, and an error will occur if the alias name is missing.
Therefore, you should change the following command as below.
conda create --prefix /anaconda_env/personal/env1 python=3.6
to
conda create -n py36 --prefix /anaconda_env/personal/env1 python=3.6
Aliases created in this way are created in the /anaconda_env/personal/env1 directory.
And to use the new alias so created,
(base) $ conda activate py36
will do.
Regards, you.
ktsh.tanaka.2020
Hello Ktsh.tanaka,
Thank you for your reply.
conda activate py36 is okay in the linux (L1) which I used to create the environment.
But the issue is in the another linux (L2) which mount the environment from L1.
I donβt know why I got the error in linux (L2).
1 Like
Hello ktsh.tanaka,
May I know do I need to install conda in linux (L2)?
Because when I check conda version
conda --version
I got the same error. But in linux (L1), I can check the conda version. The conda version in L1 is 4.8.3.
1 Like
dear 9.susan2.
thank you for reply.
The cause is unknown, but it seems that the error occurs because python lib or json under info cannot be read in the L2 environment.
Below is the tree of libraries used by conda (URL: Conda packages β conda dev documentation).
βββbin
β βββ pyflakes
βββinfo
β βββ LICENSE.txt
β βββ files
β βββ index.json
β βββ paths.json
β βββ recipe
βββ lib
βββ python3.x
When using conda with bash, csh, etc., the necessary PATH is set through a shell script in $HOME\anaconda3\etc\profile.d.
However, I think it is caused because it is not enabled on the L2 side.
Therefore, as a solution, I think it is better to allow the L2 environment side to refer to the necessary libraries.
Regards, you.
ktsh.tanaka.2020