Code Monkey home page Code Monkey logo

Comments (6)

JeremiahZhang avatar JeremiahZhang commented on August 20, 2024

问题

  • pip 和 pip3 的具体区别?

参考 回答

from gopython.

JeremiahZhang avatar JeremiahZhang commented on August 20, 2024

Pip3

anifacc@mint ~ $ python3 -m pip install --user pipenv
Collecting pipenv
  Using cached pipenv-8.2.6.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named 'setuptools'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-1bdmfp86/pipenv/
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

更新 pip3

anifacc@mint ~ $ python3 -m pip install --upgrade pip
Collecting pip
  Using cached pip-9.0.1-py2.py3-none-any.whl
Installing collected packages: pip
Successfully installed pip-8.1.1
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
anifacc@mint ~ $ python3 -m pip install --upgrade pip
Requirement already up-to-date: pip in ./.local/lib/python3.5/site-packages

只能更新到8.1.1. (猜测 因为是 python3.5, 如果是 3.6 就可以)

之前的出现问题, 提示是

 Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named 'setuptools'

解决:

anifacc@mint ~ $ sudo apt-get install python3-setuptools
[sudo] password for anifacc: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  python-setuptools-doc
The following NEW packages will be installed:
  python3-setuptools
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 88.0 kB of archives.
After this operation, 439 kB of additional disk space will be used.
Get:1 http://mirrors.aliyun.com/ubuntu xenial/main i386 python3-setuptools all 20.7.0-1 [88.0 kB]
Fetched 88.0 kB in 0s (234 kB/s)        
Selecting previously unselected package python3-setuptools.
(Reading database ... 350886 files and directories currently installed.)
Preparing to unpack .../python3-setuptools_20.7.0-1_all.deb ...
Unpacking python3-setuptools (20.7.0-1) ...
Setting up python3-setuptools (20.7.0-1) ...

然后安装 pipenv 就没问题.

anifacc@mint ~ $ pip3 install --user pipenv
Collecting pipenv
  Using cached pipenv-8.2.6.tar.gz
Collecting virtualenv (from pipenv)
  Using cached virtualenv-15.1.0-py2.py3-none-any.whl
Collecting pew>=0.1.26 (from pipenv)
  Using cached pew-0.1.27-py2.py3-none-any.whl
Requirement already satisfied: pip>=9.0.1 in ./.local/lib/python3.5/site-packages (from pipenv)
Collecting requests>2.18.0 (from pipenv)
  Using cached requests-2.18.4-py2.py3-none-any.whl
Collecting flake8 (from pipenv)
  Using cached flake8-3.4.1-py2.py3-none-any.whl
Collecting urllib3>=1.21.1 (from pipenv)
  Using cached urllib3-1.22-py2.py3-none-any.whl
Collecting virtualenv-clone>=0.2.5 (from pew>=0.1.26->pipenv)
  Using cached virtualenv-clone-0.2.6.tar.gz
Requirement already satisfied: setuptools>=17.1 in /usr/lib/python3/dist-packages (from pew>=0.1.26->pipenv)
Collecting chardet<3.1.0,>=3.0.2 (from requests>2.18.0->pipenv)
  Using cached chardet-3.0.4-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests>2.18.0->pipenv)
  Using cached certifi-2017.7.27.1-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests>2.18.0->pipenv)
  Using cached idna-2.6-py2.py3-none-any.whl
Collecting pyflakes<1.6.0,>=1.5.0 (from flake8->pipenv)
  Using cached pyflakes-1.5.0-py2.py3-none-any.whl
Collecting pycodestyle<2.4.0,>=2.0.0 (from flake8->pipenv)
  Using cached pycodestyle-2.3.1-py2.py3-none-any.whl
Collecting mccabe<0.7.0,>=0.6.0 (from flake8->pipenv)
  Using cached mccabe-0.6.1-py2.py3-none-any.whl
Installing collected packages: virtualenv, virtualenv-clone, pew, chardet, certifi, idna, urllib3, requests, pyflakes, pycodestyle, mccabe, flake8, pipenv
  Running setup.py install for virtualenv-clone ... done
  Running setup.py install for pipenv ... done
Successfully installed certifi-2017.7.27.1 chardet-3.0.4 flake8-3.4.1 idna-2.6 mccabe-0.6.1 pew-0.1.27 pipenv-8.2.6 pycodestyle-2.3.1 pyflakes-1.5.0 requests-2.18.4 urllib3-1.22 virtualenv-15.1.0 virtualenv-clone-0.2.6

因此, 多看 原有的 error 提示.

from gopython.

JeremiahZhang avatar JeremiahZhang commented on August 20, 2024

Now

  • pip 安装 pipenv 完成
  • pip3 安装 pipenv 完成

from gopython.

JeremiahZhang avatar JeremiahZhang commented on August 20, 2024

使用 Pipenv 参考

from gopython.

JeremiahZhang avatar JeremiahZhang commented on August 20, 2024

Usage

anifacc@mint /media/anifacc/geek/youtube_download $ pipenv --three install pafy
Creating a virtualenv for this project…
Using /usr/bin/python3 to create virtualenv…
⠋Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/anifacc/.local/share/virtualenvs/youtube_download-YJRREo8d/bin/python3
Also creating executable in /home/anifacc/.local/share/virtualenvs/youtube_download-YJRREo8d/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /home/anifacc/.local/share/virtualenvs/youtube_download-YJRREo8d
Creating a Pipfile for this project…
Installing pafy…
Collecting pafy
  Downloading pafy-0.5.3.1.tar.gz
Building wheels for collected packages: pafy
  Running setup.py bdist_wheel for pafy: started
  Running setup.py bdist_wheel for pafy: finished with status 'done'
  Stored in directory: /home/anifacc/.cache/pip/wheels/1d/81/dc/0cb0b1eea7b67d3d85e52764f8de1cebc0800e7c7bca8480c6
Successfully built pafy
Installing collected packages: pafy
Successfully installed pafy-0.5.3.1

Adding pafy to Pipfile's [packages]…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (3a86d5)!
anifacc@mint /media/anifacc/geek/youtube_download $ ls
Pipfile  Pipfile.lock

再来一次:

anifacc@mint /media/anifacc/geek/youtube_download $ pipenv --three install
Virtualenv already exists!
Removing existing virtualenv…
Creating a virtualenv for this project…
Using /usr/bin/python3 to create virtualenv…
⠋Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/anifacc/.local/share/virtualenvs/youtube_download-YJRREo8d/bin/python3
Also creating executable in /home/anifacc/.local/share/virtualenvs/youtube_download-YJRREo8d/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /home/anifacc/.local/share/virtualenvs/youtube_download-YJRREo8d
Installing dependencies from Pipfile.lock (3a86d5)…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 1/1 — 00:00:03
To activate this project's virtualenv, run the following:
 $ pipenv shell

先前的 virtual environment 已经移除.

anifacc@mint /media/anifacc/geek/youtube_download $ cat Pipfile
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[packages]
pafy = "*"

[requires]
python_version = "3.5"

from gopython.

JeremiahZhang avatar JeremiahZhang commented on August 20, 2024

Running your code

[dev-packages]anifacc@mint /media/anifacc/geek/youtube_download $ pipenv shell
Spawning environment shell (/bin/bash). Use 'exit' to leave.
source /home/anifacc/.local/share/virtualenvs/youtube_download-YJRREo8d/bin/activate
anifacc@mint /media/anifacc/geek/youtube_download $ source /home/anifacc/.local/share/virtualenvs/youtube_download-YJRREo8d/bin/activate
(youtube_download-YJRREo8d) anifacc@mint /media/anifacc/geek/youtube_download $ python
Python 3.5.2 (default, Aug 18 2017, 17:48:00) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

看 python virtual envs

anifacc@mint /media/anifacc/geek/youtube_download $ pipenv run which python
/home/anifacc/.local/share/virtualenvs/youtube_download-YJRREo8d/bin/python

可以 这样 跑程序:

pipenv run python my_project.py

简介些, 可以在 shell 脚本中 加入别名, 如

alias prp="pipenv run python"

from gopython.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.