Reputation: 53
I am learning Python and downloaded it with Anaconda in Ubuntu (learning Linux too). When I create a conda environment, it generates a directory with the name of the env like this: /home/user/anaconda3/envs/myenv1
When I activate the environment and launch my editor (VScode) I then select the interpreter from the active environment. When I save my .py file, do I have to save it inside the environment directory? That folder contains other folders and packages that are put there by conda. If I need a package from that environment and my project folder is not in the myenv1 directory, will it not work?
Upvotes: 5
Views: 6600
Reputation: 10960
Until and unless you are inside the environment i.e. environment is activated, you'll have access to all packages installed in the conda environment. Run the python file inside the environment. There is no requirement of placing your project inside the environment.
Go to your project directory then open terminal or open terminal in VSCode then put this command
conda activate myenv1
If the environment is activated, it will be shown in left part of your bash prompt like
(myenv1) username: /path/to/project $
Then,
python my_script.py
Upvotes: 4
Reputation: 33
No, you don't have to save any file in the virtual environment folder. Once the environment is activated, it acts like an independent environment. But remember you will have to install all the packages again which are not available in Conda.
Upvotes: 0