Created for
$ pip install --user pipenv
### Create virtualenv with system Python3:
$ pipenv --three
Creating a virtualenv for this project…
### Spawn 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...
### install requests package and create a virenv, 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']))
(course_intro-SmgljMaj) $ python my_ip.py
exit
Or type ctrl-d
Or close your terminal windows :)
Intro to Pipenv - A Package Manager for Python by Pretty Printed
Pipenv - a talk at the San Diego Python meetup on October 26, 2017 by San Diego Python
Install Python, PIP, Virtualenv, and Django on Windows 10 with PowerShell by CodingEntrepreneurs
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 shel
Spawning environment shell...
# navigate to project folder
$ cd your/root/project/folder
# get into pipenv shell
$ pipenv shell
(my_project-hUoR8K1v) $
# get python path and copy it
(my_project-hUoR8K1v) $ which python
/home/nemsys/.local/share/virtualenvs/my_project-hUoR8K1v/bin/python
Preferences: Open Workspace Settings
python.pythonPath
in left panelYour workspace settings should look like:
{
"folders": [
{
"path": "."
}
],
"settings": {
"python.pythonPath": "/home/nemsys/.local/share/virtualenvs/my_project-hUoR8K1v/bin/python"
}
}
These slides are based on
customised version of
framework