Created for
Created by
Next slides guides you trhough the process of installing the needed tools for DataScience/ML in Python.
But if you are already comfortable with Anaconda (i.e. you know what your $PYTHON_PATH is) you should skip the next slides.
Note, we'll be using Python 3!
C:/Python3
or whatever you like
# check for python installed version:
python --versions
# check for pip installed version:
pip --version
python3
and pip3
instead.Nor to pass through the dependency hell
$ pip install --user pipenv
$ pip install --upgrade pipenv
$ pip uninstall pipenv
python -m site --user-base
# /home/username/.local
# add it to your ~/.profile or ~/.bashrc file, or:
export PATH=$PATH:/home/username/.local/bin
py -m site --user-site
#C:\Users\Username\AppData\Roaming\Python36\site-packages
# add to PATH:
C:\Users\Username\AppData\Roaming\Python36\Scripts
pipenv install packagename
### Create virtualenv with system Python3:
$ pipenv --three
Creating a virtualenv for this project…
### Spawn (activate) a shell within the virtualenv
$ pipenv shell
Spawning environment shell...
### Exit the virtualenv
(course_intro-SmgljMaj) $ exit
exit
$
### Output virtualenv information
$ pipenv --venv
### Remove the virtualenv
$ pipenv --rm
Removing virtualenv...
All options available with: pipenv --help
PIPENV_VENV_IN_PROJECT=1
, pipenv will store the virtualenv in .venv/
folder per project bases and will name the virtualenv after your project name.
### install requests package and create a virtenv, if there is no one
$ pipenv install requests
Installing requests…
### remove package
$ pipenv uninstall requests
Uninstalling requests-2.18.4
$ pipenv graph
my_ip.py
import requests
response = requests.get('https://httpbin.org/ip')
print('Your IP is {0}'.format(response.json()['origin']))
# go to your project folder:
$ cd your/project/folder
# activate the virtenv:
$ pipenv shell
# run the program within the virtenv:
(course_intro-SmgljMaj) $ python my_ip.py
exit
Or type ctrl-d
Or close your terminal window :)
# install pyenv
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
# add it to path
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
#Create a new project using Python 3.6, specifically:
$ pipenv --python 3.6
# you'll be asked by pipenv if you want it to install the Python 3.6, if it is not inyour system
Intro to Pipenv - A Package Manager for Python by Pretty Printed
Kenneth Reitz - Pipenv: The Future of Python Dependency Management - PyCon 2019
import matplotlib.pyplot as plt
import numpy as np
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2*np.pi*t)
plt.plot(t, s)
plt.xlabel('time (s)')
plt.ylabel('voltage (mV)')
plt.title('About as simple as it gets, folks')
plt.grid(True)
plt.savefig("test.png")
plt.show()
example from: matplotlib.org
# navigate...
$ cd your/project/root/folder
# make sure you are in it - get your current working directory:
$ pwd
your/project/root/folder
try to run the simple_plot.py program
$ python simple_plot.py
Traceback (most recent call last):
File "simple_plot.py", line 1, in <module>
import matplotlib.pyplot as plt
ImportError: No module named matplotlib.pyplot
Yes, an error occurs, because we do not have the required module (matplotlib) installed
We will install the required modules in a safe virtual environment by pipenv!
# install packages safely with pipenv:
$ pipenv install matplotlib
Creating a virtualenv for this project…
...
To activate this project`s virtualenv, run the following
$ pipenv shell
$ pipenv shell
Spawning environment shell...
$ pipenv install numpy
$ pipenv install pandas
$ pipenv install matplotlib
$ pipenv install seaborn
Note, in this course we will use the JupyterLab
$ pipenv install jupyterlab
$ pipenv install scikit-learn
# navigate to your project folder:
$ cd my/project/folder
# install packages:
$ pipenv install numpy pandas seaborn matplotlib jupyterlab scikit-learn
git bash
, shell integration
and more Intro to Numerical Computing with NumPy (Beginner) | SciPy 2019 Tutorial | Alex Chabot-Leclerc
These slides are based on
customised version of
framework