美文网首页
python虚拟环境搭建

python虚拟环境搭建

作者: woniuxia | 来源:发表于2020-03-30 10:30 被阅读0次

    python环境搭建:

    • 安装pyenv
    git clone https://github.com/pyenv/pyenv.git ~/.pyenv
    echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
    echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
    echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
    
    yum install readline readline-devel readline-static -y
    yum install openssl openssl-devel openssl-static -y
    yum install sqlite-devel -y
    yum install bzip2-devel bzip2-libs -y
    yum install libffi-devel -y
    
    • debian系统
    apt-get install build-essential -y
    apt-get install libncurses5-dev libncursesw5-dev libreadline6-dev -y
    apt-get install libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev -y
    apt-get install libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev -y
    apt-get install ca-certificates -y
    apt-get install python-dev python-setuptools python-pip python-smbus
    apt-get install libc6-dev tk-dev
    apt-get install libffi-dev
    
    ln /usr/lib/x86_64-linux-gnu/libssl.so.1.0.2 /usr/local/libssl.so
    ln /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.2 /usr/local/libcrypto.so
    
    • 产看所有版本:
      pyenv versions
      查看当前版本:
      pyenv version
      切换版本:
      pyenv global 3.6.5 (建议python3.7 以上版本 用centos 7 以上系统)

    • 配置豆瓣源
      HOME用户目录下
      mkdir .pip
      touch pip.conf

    • 编辑pip.conf:

    [global]
    timeout = 60
    index-url = https://pypi.doubanio.com/simple
    
    • 创建虚拟环境
      python3 -m venv venv3.6

    • 激活虚拟环境
      source venv3.6/bin/activate

    • 安装依赖包
      pip3 freeze > requirements.txt 生成依赖包
      pip3 install -r requirements.txt

    相关文章

      网友评论

          本文标题:python虚拟环境搭建

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