<jupyter_start><jupyter_text>In order to successfully complete this assignment you must do the required reading, watch the provided videos and complete all instructions.  The embedded Google form must be entirely filled out and submitted on or before **11:59pm on Tuesday January 14**.  Students must come to class the next day prepared to discuss the material covered in this assignment. answer  Pre-Class Assignment: Python Environments  Goals for today's pre-class assignment 1. [Syntax Review - Importing packages](Importing_packages)1. [Python Paths](Python_Paths)2. [Root vs Local Installs](Root_vs_Local_Installs)3. [Conda Environments](Conda_Environments)4. [Debugging Review](Debugging)4. [Assignment wrap-up](Assignment_wrap-up) ---- 1. Syntax Review - Importing packages If you still find the ```import``` syntax to be a little confusing consider following along with this optional and slightly longer video.<jupyter_code>from IPython.display import YouTubeVideo
YouTubeVideo("NjK0ix3MR5g",width=640,height=360, cc_load_policy=True)<jupyter_output><empty_output><jupyter_text>--- 2. Python PathsIn order to understand how packages and software work in Python it is helpful to understand the Python search path.  The search path is a list of folders that Python looks through when an  ```import``` command is issued.  The following code lists the current search path:<jupyter_code>import sys
sys.path<jupyter_output><empty_output><jupyter_text>--- 3. Root vs Local Installs Most python programmers have installed third party packages(Python Package Index-PyPI)  at one time or another.  The two major installation programs avaliable to python are ```conda``` and ```pip``` but there are also others.  Lets look at both by doing some example installs When using python package installers such as ```pip``` and ```conda install``` the packages software is installed into your Anaconda python path.  THis is okay if you own the computer but may cause problems if there are multiple users. Also, I don't like to install software in the default paths if you are just testing or are not sure the packages will do what you want.  One thing you can do is install the software in a local folder.  Using the ```pip``` command to install packages into a specific folder.<jupyter_code>from IPython.display import YouTubeVideo
YouTubeVideo("lHUrjoCA1C8",width=640,height=360, cc_load_policy=True)<jupyter_output><empty_output><jupyter_text>Lets try the [Seaborn package](http://seaborn.pydata.org/) using the pip install command with the "target" folder option:<jupyter_code>#!pip install -t ./packages/ seaborn<jupyter_output><empty_output><jupyter_text>Now add the new ./packages/ library to the python system path:<jupyter_code># Command to add packages path to system path:
import sys
sys.path.append('./packages/')<jupyter_output><empty_output><jupyter_text>Now you should be able to install and test the library<jupyter_code>import seaborn
help(seaborn)<jupyter_output><empty_output><jupyter_text>**Question 3:** What does the ```-t``` argument do in the above pip command? Put your answer to the above question here ----- 4.  Local Conda EnvironmentsOne of the best ways to install and test Python packages is to use Conda Environments on the command line.  The following are some instructions the instructor likes to use to install and test local libraries.  In this example we will use the ```--prefix``` option and make a library called ```envs```:    conda create --prefix ./envs matplotlib numpy mdtraj h5py networkx Make sure you hit ```Y``` and install all of the packages and their dependencies. Once everything is installed you can activate the environment as follows:    conda activate ./envs Once you are done using the environment it can be deactivated    conda deactivate Once you are done using the environment you can free up the space by just deleting the directory:    rm -rf ./envs If your research project uses a lot of external libraries you may want to create an ./envs in your project folder. Do not commit third party packages to your repository but this can be a helpful way to keep things organized.    ---- 5. Debugging ReviewHere is a quick video you can review about debugging.<jupyter_code>from IPython.display import YouTubeVideo
YouTubeVideo("TSWXvhAy2Wc",width=640,height=360, cc_load_policy=True)<jupyter_output><empty_output><jupyter_text>---- 6. Assignment wrap-upPlease fill out the form that appears when you run the code below.  **You must completely fill this out in order to receive credit for the assignment!**[Direct Link to Google Form](https://cmse.msu.edu/cmse314-pc-survey)If you have trouble with the embedded form, please make sure you log on with your MSU google account at [googleapps.msu.edu](https://googleapps.msu.edu) and then click on the direct link above. &9989; **Assignment-Specific QUESTION:** Explain why we do not recommend using the "from library import *" syntax? Put your answer to the above question here &9989; **QUESTION:**  Summarize what you did in this assignment. Put your answer to the above question here &9989; **QUESTION:**  What questions do you have, if any, about any of the topics discussed in this assignment after working through the jupyter notebook? Put your answer to the above question here &9989; **QUESTION:**  How well do you feel this assignment helped you to achieve a better understanding of the above mentioned topic(s)? Put your answer to the above question here &9989; **QUESTION:** What was the **most** challenging part of this assignment for you?  Put your answer to the above question here &9989; **QUESTION:** What was the **least** challenging part of this assignment for you?  Put your answer to the above question here &9989; **QUESTION:**  What kind of additional questions or support, if any, do you feel you need to have a better understanding of the content in this assignment? Put your answer to the above question here &9989; **QUESTION:**  Do you have any further questions or comments about this material, or anything else that's going on in class? Put your answer to the above question here &9989; **QUESTION:** Approximately how long did this pre-class assignment take? Put your answer to the above question here<jupyter_code>from IPython.display import HTML
HTML(
"""
<iframe 
	src="https://cmse.msu.edu/cmse314-pc-survey" 
	width="100%" 
	height="1000px" 
	frameborder="0" 
	marginheight="0" 
	marginwidth="0">
	Loading...
</iframe>
"""
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07584399568367504, 'fraction_numerical': 0.014798828426082935, 'mean_word_length': 5.196752626552054, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '601865', 'license': 'MIT', 'n_tokens_mistral': 1786, 'n_tokens_neox': 1685, 'n_words': 860, 'path': 'cmse802-s20/0114--Installing_Packages-pre-class-assignment.ipynb', 'repo_name': 'Diane1306/cmse802_git_CompModelling', 'size': '6487'}