美文网首页
pipenv的使用

pipenv的使用

作者: oldwai | 来源:发表于2019-11-24 21:30 被阅读0次

    pipenv是pip和virtualenv的合体,用来管理python环境,因为是在国内使用,建议替换成国内源,参考地址 :

    使用需要先安装python、pip和pipenv,请自行百度,安装完成后,进行pipenv安装

      pip install pipenv
    

    经常出现下载慢或者链接超时的问题,请使用windows系统的童鞋修改源:

      (1):在windows文件管理器中,输入 %APPDATA%
    
      (2):会定位到一个新的目录下,在该目录下新建pip文件夹,然后到pip文件夹里面去新建个pip.ini文件
    
      (3):在新建的pip.ini文件中输入以下内容,搞定文件路   径:"C:\Users\Administrator\AppData\Roaming\pip\pip.ini"
      [global]
          index-url = https://pypi.doubanio.com/simple
      [install]
          trusted-host = pypi.doubanio.com
    

    用法

    1、打开终端(cmder/terminal),进入到项目根目录下,执行

            pipenv install     #默认环境变量里配置的python版本
    
            pipenv --python path-to-python   #指定python版本安装虚拟环境,也可用 pipenv --three
    

    2、进入虚拟环境,安装各种依赖包:

            pipenv shell
    
            pipenv install -r requirements.txt     #项目之前使用requirements.txt管理包,可以切换一下
    

    PS:具体使用命令不一一详解,请参考:

    (practice_floder-FsVo9ztC) λ pipenv -h                                        
    Usage: pipenv [OPTIONS] COMMAND [ARGS]...                                     
                                                                                  
    Options:                                                                      
      --where             Output project home information.                        
      --venv              Output virtualenv information.                          
      --py                Output Python interpreter information.                  
      --envs              Output Environment Variable options.                    
      --rm                Remove the virtualenv.                                  
      --bare              Minimal output.                                         
      --completion        Output completion (to be eval'd).                       
      --man               Display manpage.                                        
      --support           Output diagnostic information for use in GitHub issues. 
      --site-packages     Enable site-packages for the virtualenv.  [env var:     
                          PIPENV_SITE_PACKAGES]                                   
      --python TEXT       Specify which version of Python virtualenv should use.  
      --three / --two     Use Python 3/2 when creating virtualenv.                
      --clear             Clears caches (pipenv, pip, and pip-tools).  [env var:  
                          PIPENV_CLEAR]                                           
      -v, --verbose       Verbose mode.                                           
      --pypi-mirror TEXT  Specify a PyPI mirror.                                  
      --version           Show the version and exit.                              
      -h, --help          Show this message and exit.                             
                                                                                  
                                                                                  
    Usage Examples:                                                               
       Create a new project using Python 3.7, specifically:                       
       $ pipenv --python 3.7                                                      
                                                                                  
       Remove project virtualenv (inferred from current directory):               
       $ pipenv --rm                                                              
                                                                                  
       Install all dependencies for a project (including dev):                    
       $ pipenv install --dev                                                     
                                                                                  
       Create a lockfile containing pre-releases:                                 
       $ pipenv lock --pre                                                        
                                                                                  
       Show a graph of your installed dependencies:                               
       $ pipenv graph                                                             
                                                                                  
       Check your installed dependencies for security vulnerabilities:            
       $ pipenv check                                                             
                                                                                  
       Install a local setup.py into your virtual environment/Pipfile:            
       $ pipenv install -e .                                                      
                                                                                  
       Use a lower-level pip command:                                             
       $ pipenv run pip freeze                                                    
                                                                                  
    Commands:                                                                     
      check      Checks for security vulnerabilities and against PEP 508 markers  
                 provided in Pipfile.                                             
      clean      Uninstalls all packages not specified in Pipfile.lock.           
      graph      Displays currently-installed dependency graph information.       
      install    Installs provided packages and adds them to Pipfile, or (if no   
                 packages are given), installs all packages from Pipfile.         
      lock       Generates Pipfile.lock.                                          
      open       View a given module in your editor.                              
      run        Spawns a command installed into the virtualenv.                  
      shell      Spawns a shell within the virtualenv.                            
      sync       Installs all packages specified in Pipfile.lock.                 
      uninstall  Un-installs a provided package and removes it from Pipfile.      
      update     Runs lock, then sync. 
    

    常见问题:

      pipenv.patched.notpip._vendor.urllib3.exceptions.ReadTimeoutError:        
      HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
    

    相关文章

      网友评论

          本文标题:pipenv的使用

          本文链接:https://www.haomeiwen.com/subject/tyjrwctx.html