1

Okay so I created a conda environment conda create --name myfirstenv then I did conda activate myfirstenv, and installed a bunch of packages like openpyxl and jupyter notebook and whatever. So where do I place my files, like let's say I create an automation.py file which does some automation with csv reader or whatever, do the files go inside the myfirstenv environment?

Shah Jacob
  • 137
  • 1
  • 9

1 Answers1

3

No, your environment folder contains the dependencies and python execute file to run your code. As for your project files, it can be anywhere. When you want to run the files, you active the environment to use the python and the dependencies inside of it to run the files.

UMR
  • 310
  • 4
  • 16
  • 1
    I just want to even more emphasize: Don't put projects *in* your environment! Environments are available to you through the shell or Jupyter kernel registration or `conda run`, etc.. They are meant to be isolated and managed by Conda only. – merv Apr 11 '21 at 06:05
  • so 1) how do i know where the envs directory is stored (is it true all the conda envs are stored in an env directory) 2) so to respond to your answer, if for example i made a directory in my desktop called automation_project/, i can just do conda activate my_env and it'll work? 3) how do i run the script in the environment or outside of the environment? – Shah Jacob Apr 11 '21 at 06:11
  • 1) I think the answer you are looking for is here https://stackoverflow.com/a/47277111/9186481 2) Yes 3) In case you want to run your code on another computer, for example, you create a requirements.txt file, which contains the name and the version of all the dependencies inside the environment. Then at the new computer, you set up a new environment and install all dependencies as listed in the requirements file. Check this answer https://stackoverflow.com/questions/50777849/from-conda-create-requirements-txt-for-pip3 – UMR Apr 11 '21 at 06:19
  • If you have activated the environment, you can just run it as usual such as `python3 filename.py`. the filename.py will be run using the environment's python3 and dependencies @ShahJacob – UMR Apr 11 '21 at 06:23
  • I’m really confused. What is a requirements txt file and what does it do. Let’s say I have a virtual environment in my desktop and it’s Python 3.6 instead of Python 3.9 and has older version numbers of pandas and openpyxl and beautifulsoup4 (these are Python packages). If I wanted someone else to run this app how would I get them to know exactly what version numbers of the packages I have installed? Do I just do conda list and manually copy them into a txt file. The thing is I have Jupyter notebook installed and it comes with a shit ton of packages – Shah Jacob Apr 13 '21 at 04:11
  • How do I make a file that tells the person like in a readme.md file what version numbers of packages I have installed? Do I do it manually or is there anyway to do it automatically? If I wanted to do it manually would I need to use a for loop or something to do this and iterate over every package in conda list command and then write that into a text file? Or is there a way to automatically generate this like is there a convenient command in conda that does for me so I don’t have to spend like an hour doing it manually? – Shah Jacob Apr 13 '21 at 04:16
  • Here is an example of what inside requiremets.txt file APScheduler==3.7.0 asgiref==3.3.1 astroid==2.5.1 attrs==20.3.0 backcall==0.2.0 .As how to created it, I have mentioned in the above comment – UMR Apr 13 '21 at 04:29
  • Here is how to use requirements.txt file https://stackoverflow.com/questions/51042589/conda-version-pip-install-r-requirements-txt-target-lib/51043636 – UMR Apr 13 '21 at 04:31