Python Forum
Thread Rating:
  • 3 Vote(s) - 2.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pipenv
#1
Pipenv is now the official recommended Python packaging tool from Python.org.
The documentation look at this video for usage.

I did test it in a earlier stage then it did not work for Windows,
now is all OS supported.

Here a test and usage of Pipenv with Windows.
pip install -U pipenv
# make a folder
E:\1
λ mkdir web_title

# cd in
E:\1
λ cd web_title
E:\1\web_title

# Activate shell
λ pipenv shell
Creating a Pipfile for this project...
Creating a virtualenv for this project...
Using base prefix 'c:\\python36'
....
Installing setuptools, pip, wheel...done.
At this point this empty folder is a virtual environment.
Can look a Python and pip placement.
E:\1\web_title
λ pipenv --venv
C:\Users\Tom\.virtualenvs\web_title-vYANOqhT

 E:\1\web_title
λ which python
/c/Users/Tom/.virtualenvs/web_title-vYANOqhT/Scripts/python

E:\1\web_title
λ pip -V
pip 9.0.1 from c:\users\tom\.virtualenvs\web_title-vyanoqht\lib\site-packages (python 3.6)
Place a file in this folder.
# find_title.py
import requests
from bs4 import BeautifulSoup

def web_title(url):
    '''find web site title'''
    url_get = requests.get(url)
    soup = BeautifulSoup(url_get.content, 'lxml')
    print(soup.select('head > title')[0].text)

if __name__ == '__main__':
    #url = 'http://CNN.com'
    url = 'https://www.python.org/'
    web_title(url)
Try to run the file.
E:\1\web_title
λ python find_title.py
Traceback (most recent call last):
  File "find_title.py", line 2, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'
Pipenv works like pip,so need to install Requests,BeautifulSoup and lxml.
E:\1\web_title
λ pipenv install beautifulsoup4 requests lxml

# Run again
E:\1\web_title
λ python find_title.py
Welcome to Python.org
Look at dependencies with graph command.
E:\1\web_title
λ pipenv graph
beautifulsoup4==4.6.0
lxml==3.8.0
pip==9.0.1
requests==2.18.4
  - certifi [required: >=2017.4.17, installed: 2017.7.27.1]
  - chardet [required: <3.1.0,>=3.0.2, installed: 3.0.4]
  - idna [required: >=2.5,<2.7, installed: 2.6]
  - urllib3 [required: <1.23,>=1.21.1, installed: 1.22]
setuptools==36.4.0
wheel==0.30.0
So all work,to get out shell modus(virtualenv) type exit.

If want run in a editor is the same way as with virtual environment.
Point to Python version used in environment.
I use VS code,so there is a setting.json file where i can select workspace interpreter.
{
"python.pythonPath": "C:\Users\Tom\.virtualenvs\web_title-vYANOqhT\python.exe"
}
[Image: HBSXCv.jpg]
Reply


Messages In This Thread
Pipenv - by snippsat - Sep-11-2017, 05:12 PM
RE: Pipenv - by nilamo - Sep-11-2017, 08:24 PM
RE: Pipenv - by snippsat - Sep-11-2017, 09:14 PM
RE: Pipenv - by nilamo - Sep-11-2017, 09:16 PM
RE: Pipenv - by snippsat - Sep-11-2017, 09:27 PM
RE: Pipenv - by Larz60+ - Sep-12-2017, 10:01 PM
RE: Pipenv - by snippsat - Sep-18-2017, 01:34 PM
RE: Pipenv - by Larz60+ - Sep-18-2017, 01:56 PM
RE: Pipenv - by snippsat - Sep-18-2017, 09:15 PM
RE: Pipenv - by Larz60+ - Sep-18-2017, 09:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  update python in pipenv tdwinfre 1 1,771 Nov-11-2020, 01:45 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020