相关疑难解决方法(0)

如何使用Python 3.x和Python 2.x一起使用pip

我安装了Python 3.x(除了Ubuntu上的Python 2.x)并慢慢开始配对我在Python 2.x中使用的模块.

所以我想知道,对于Python 2.x和Python 3.x,我应该采用什么方法让pip变得简单?

python pip python-2.7 python-3.x

187
推荐指数
7
解决办法
19万
查看次数

python3中没有名为“beautifulsoup4”的模块

$ virtualenv test
$ source test/bin/activate
$ pip3 install beautifulsoup4
Run Code Online (Sandbox Code Playgroud)

现在脚本 test.py

import urllib.request
import sys
import unittest, time, re

import requests
from bs4 import BeautifulSoup

class Sel(unittest.TestCase):

    def setUp(self):
        self.base_url = "file:///Users/ishandutta2007/Desktop/cars/cars-price-list.html"

    def test_sel(self):
        with urllib.request.urlopen(self.base_url) as url:
            html_source = url.read()
        data = html_source#.encode('utf-8')
        parsed_html = BeautifulSoup(data, 'html.parser')

if __name__ == "__main__":
    unittest.main()
Run Code Online (Sandbox Code Playgroud)

当我跑 $python3 test.py

文件“test.py”,第 6 行,在 from bs4 import BeautifulSoup ModuleNotFoundError: No module named 'bs4'

然后尝试

from beautifulsoup4 import BeautifulSoup
Run Code Online (Sandbox Code Playgroud)

文件“test.py”,第 6 行,在 from beautifulsoup4 import …

python beautifulsoup python-3.x

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×2

python-3.x ×2

beautifulsoup ×1

pip ×1

python-2.7 ×1