Build Python DevEnv with pipenv
Install python3.6.5
First, install python3.6.5 because pipenv didn’t work well with python3.7 on my Mac(Mojave). So I gave up using python3.7. (According to the official site pipenv doesn’t support python3.7 lol)
https://pipenv.readthedocs.io/en/latest/
$ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb🍺 /usr/local/Cellar/python/3.6.5_1: 9,143 files, 154.7MB, built in 18 minutes 32 secondsTake so much time orzcheck python version
$ python3 --version
Python 3.6.5$ pip3 --version
pip 10.0.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
Install pipenv
Next step is to install pipenv. There are 3ways. The first one is to use homebrew, another is to use pip and the other is to user curl.
$ brew install pipenv
$ pip3 install --user --upgrade pipenv (if you use pyenv, the command might be pip)
$ curl https://raw.githubusercontent.com/kennethreitz/pipenv/master/get-pipenv.py | python
In this time, I used the first one because using brew is always easy(Actually, sometimes it causes many troubles)
$ pip3 install --user --upgrade pipenv
Successfully installed pipenv-2018.7.1 virtualenv-16.0.0 virtualenv-clone-0.3.0
Create a new environment with pipenv
create a folder
$ mkdir pythondev
$ cd pythondev
$ pipenv installCreating a virtualenv for this project...
Pipfile: /Users/kj/Desktop/pythondev/Pipfile
Using /usr/local/Cellar/pipenv/2018.7.1/libexec/bin/python3.7 (3.7.0) to create virtualenv...
⠋Already using interpreter /usr/local/Cellar/pipenv/2018.7.1/libexec/bin/python3.7
Using real prefix '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/kj/.local/share/virtualenvs/pythondev-Ma6Z-8Ad/bin/python3.7
Also creating executable in /Users/kj/.local/share/virtualenvs/pythondev-Ma6Z-8Ad/bin/python
Installing setuptools, pip, wheel...done.
Setting project for pythondev-Ma6Z-8Ad to /Users/kj/Desktop/pythondevVirtualenv location: /Users/kj/.local/share/virtualenvs/pythondev-Ma6Z-8Ad
Creating a Pipfile for this project...
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Updated Pipfile.lock (a65489)!
Installing dependencies from Pipfile.lock (a65489)...
🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.WHYYYYYYYYYYYYYYYYYYYYYYYYYY, not sure brew really wants to use python3.7, but could initialize a python environment
If you pipenv works properly, you can see Pipfile and Pipfile.lock in your directory and it looks like the following.
Pipfile
[[source]]
url = “https://pypi.org/simple"
verify_ssl = true
name = “pypi”
[packages]
[dev-packages]
[requires]
python_version = “3.7”Pipfile.lock
{
“_meta”: {
“hash”: {
“sha256”: “7e7ef69da7248742e869378f8421880cf8f0017f96d94d086813baa518a65489”$
},
“pipfile-spec”: 6,
“requires”: {
“python_version”: “3.7”
},
“sources”: [
{
“name”: “pypi”,
“url”: “https://pypi.org/simple”,
“verify_ssl”: true
}
]
},
“default”: {},
“develop”: {}
}
Activate python environment
$ pipenv shell(pythondev-Ma6Z-8Ad) ➜ pythondev
Install python module
$ pipenv install numpycat Pipfile
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"[packages]
numpy = "*"[dev-packages][requires]
python_version = "3.7"