Pipenv - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: Pipenv (/thread-4867.html) |
Pipenv - snippsat - Sep-11-2017 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.orgLook 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.0So 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] RE: Pipenv - nilamo - Sep-11-2017 (Sep-11-2017, 05:12 PM)snippsat Wrote: If want run in a editor is the same way as with virtual environment. That'd use the same interpreter as the virtual env, but it wouldn't use the same environment. So if you run your stuff through vs code, it'd use the global pip modules. RE: Pipenv - snippsat - Sep-11-2017 Yes you are right, i have to set interpreter in Code runner user setting if i use that to run. "php": "php", "python": "C:\\Users\\Tom\\.virtualenvs\\web_title-vYANOqhT\\Scripts\\python.exe", "perl": "perl",Usually i just run from integrated terminal with activated shell. RE: Pipenv - nilamo - Sep-11-2017 It looks like maybe you can use something like pipenv run python to start up the interpreter within the right environment: http://docs.pipenv.org/en/latest/#pipenv-run
RE: Pipenv - snippsat - Sep-11-2017 Yes i think that would work fine. I have not used Pipenv so much yet, so will for sure try to use it more now that it's stable and work for all OS. RE: Pipenv - Larz60+ - Sep-12-2017 While trying to install wxpython using pipenv, got the following error message: The package appears to be installed, but I'm concerned that something is missing.Tried -e option ( pipenv install -e wxpython) and got: Installing -e wxpython... Error: An error occurred while installing -e wxpython! Not sure I'm Ok, haven't got that warm fuzzy feeling!What do you think? RE: Pipenv - snippsat - Sep-18-2017 (Sep-12-2017, 10:01 PM)Larz60+ Wrote: What do you think?Try again after update pip install -U pipenv It's been updated 5-6 times after i post,so a lot of development is going on. One of the newest feature. Automatic Python Installation So can call pyenv if installed,to do automatic installation of Python. RE: Pipenv - Larz60+ - Sep-18-2017 Thanks, I'll give it a go RE: Pipenv - snippsat - Sep-18-2017 I had that error earlier with wxpython,newest version is gone. RE: Pipenv - Larz60+ - Sep-18-2017 Great, I love this concept, and want to use it going forward! |