pycharm创建虚拟环境遇到的问题

当我创建项目pythonProject2时,选择D:\Anaconda3\envs\python38_at\python.exe作为Base Interpreter,然后pip安装包时有如下报错:

(venv) PS D:\Pythoncoding\pachong\pythonProject2> pip install scrapy
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/scrapy/
Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/scrapy/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Max retries exceeded with url: /simple/scrapy/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement scrapy (from versions: none)
ERROR: No matching distribution found for scrapy
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
WARNING: There was an error checking the latest version of pip.
(venv) PS D:\Pythoncoding\pachong\pythonProject2>

我怀疑是Base Interpreter的问题,所以我换了其他的Base Interpreter:D:\Anaconda3\envs\python388\python.exe,重新创建了一个项目pythonProject3,然后安装相同的包,结果安装成功了。

(venv) PS D:\Pythoncoding\pachong\spiderTest02> pip install scrapy
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting scrapy
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/08/66/22ed9609df4b6d94a66512572a11b35943a6cb36dc268f88ebfbede60be1/Scrapy-2.11.0-py2.py3-none-any.whl (286 kB)
Collecting PyDispatcher>=2.0.5
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/66/0e/9ee7bc0b48ec45d93b302fa2d787830dca4dc454d31a237faa5815995988/PyDispatcher-2.0.7-py3-none-any.whl (12 kB)
Collecting zope.interface>=5.1.0
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/70/c1/b1e1fb48b5ad730f253cf9b1b72a662a577c46548c83750dc883f3b9cbad/zope.interface-6.0-cp38-cp38-win_amd64.whl (204 kB)
Collecting cssselect>=0.9.1
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/06/a9/2da08717a6862c48f1d61ef957a7bba171e7eefa6c0aa0ceb96a140c2a6b/cssselect-1.2.0-py2.py3-none-any.whl (18 kB)
Collecting w3lib>=1.17.0
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/82/e2/dcf8573d7153194eb673347cea1f9bbdb2a8e61030740fb6f50e4234a00b/w3lib-2.1.2-py3-none-any.whl (21 kB)
Collecting pyOpenSSL>=21.0.0
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/f0/e2/f8b4f1c67933a4907e52228241f4bd52169f3196b70af04403b29c63238a/pyOpenSSL-23.2.0-py3-none-any.whl (59 kB)
Collecting protego>=0.1.15
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/bc/16/14fd1ecdece2e1d87279fc09fbd2d55bae5fa033783c3547af631c74d718/Protego-0.3.0-py2.py3-none-any.whl (8.5 kB)
Collecting Twisted<23.8.0,>=18.9.0
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ac/63/b5540d15dfeb7388fbe12fa55a902c118fd2b324be5430cdeac0c0439489/Twisted-22.10.0-py3-none-any.whl (3.1 MB)
Collecting itemloaders>=1.0.1
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/9a/98/d03afe36d01b1adf03435bb306d0e7f87d498c94ba8db5290f716b350bb8/itemloaders-1.1.0-py3-none-any.whl (11 kB)
Collecting cryptography>=36.0.0
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/d7/78/29d8332bebfe3c2d49a63fb23e1c9fc73a13507b5206b98479fda04c993b/cryptography-41.0.4-cp37-abi3-win_amd64.whl (2.7 MB)
Collecting tldextract
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/76/a6/adc68851ae4a7fd6a02ad5c1c2f4533d5811c64558bfaa583a61b0e312b5/tldextract-3.6.0-py3-none-any.whl (97 kB)
Requirement already satisfied: setuptools in d:\pythoncoding\pachong\spidertest02\venv\lib\site-packages (from scrapy) (65.5.1)
Collecting queuelib>=1.4.2
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/06/1e/9e3bfb6a10253f5d95acfed9c5732f4abc2ef87bdf985594ddfb99d222da/queuelib-1.6.2-py2.py3-none-any.whl (13 kB)
Collecting service-identity>=18.1.0
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/0c/42/bf07f277b45da6e350df3314804aa2b5411e0938d3b78b4f17da2e1302c2/service_identity-23.1.0-py3-none-any.whl (12 kB)
Collecting lxml>=4.4.1
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/7a/2f/61afbbb627e910d83613f198ceea270376f6708f52a95b534db10c67b4eb/lxml-4.9.3-cp38-cp38-win_amd64.whl (3.9 MB)
Collecting packaging
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ab/c3/57f0601a2d4fe15de7a553c00adbc901425661bf048f2a22dfc500caf121/packaging-23.1-py3-none-any.whl (48 kB)
Collecting itemadapter>=0.1.0
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/3b/9e/e1a5a2882d5a3cbf9018d18102edc4cc34de8a207e6c5eb765784298fb48/itemadapter-0.8.0-py3-none-any.whl (11 kB)
Collecting parsel>=1.5.0
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/36/d9/b67d9f251a69037c79bac90f975c84696f5ca68045bd1b97e68804625757/parsel-1.8.1-py2.py3-none-any.whl (17 kB)
Collecting cffi>=1.12
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/c9/e3/0a52838832408cfbbf3a59cb19bcd17e64eb33795c9710ca7d29ae10b5b7/cffi-1.15.1-cp38-cp38-win_amd64.whl (178 kB)
Collecting jmespath>=0.9.5
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/31/b4/b9b800c45527aadd64d5b442f9b932b00648617eb5d63d2c7a6587b7cafc/jmespath-1.0.1-py3-none-any.whl (20 kB)
Collecting pyasn1
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/14/e5/b56a725cbde139aa960c26a1a3ca4d4af437282e20b5314ee6a3501e7dfc/pyasn1-0.5.0-py2.py3-none-any.whl (83 kB)
Collecting attrs>=19.1.0
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/f0/eb/fcb708c7bf5056045e9e98f62b93bd7467eb718b0202e7698eb11d66416c/attrs-23.1.0-py3-none-any.whl (61 kB)
Collecting pyasn1-modules
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/cd/8e/bea464350e1b8c6ed0da3a312659cb648804a08af6cacc6435867f74f8bd/pyasn1_modules-0.3.0-py2.py3-none-any.whl (181 kB)
Collecting constantly>=15.1
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/b9/65/48c1909d0c0aeae6c10213340ce682db01b48ea900a7d9fce7a7910ff318/constantly-15.1.0-py2.py3-none-any.whl (7.9 kB)
Collecting hyperlink>=17.1.1
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/6e/aa/8caf6a0a3e62863cbb9dab27135660acba46903b703e224f14f447e57934/hyperlink-21.0.0-py2.py3-none-any.whl (74 kB)
Collecting twisted-iocpsupport<2,>=1.0.2
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/cc/ad/a88250f2933c5ad8170d4ee3688a8b6ac4d8c097ff136be8db790ae2b920/twisted_iocpsupport-1.0.4-cp38-cp38-win_amd64.whl (47 kB)
Collecting incremental>=21.3.0
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/77/51/8073577012492fcd15628e811db585f447c500fa407e944ab3a18ec55fb7/incremental-22.10.0-py2.py3-none-any.whl (16 kB)
Collecting typing-extensions>=3.6.5
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/24/21/7d397a4b7934ff4028987914ac1044d3b7d52712f30e2ac7a2ae5bc86dd0/typing_extensions-4.8.0-py3-none-any.whl (31 kB)
Collecting Automat>=0.8.0
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/29/90/64aabce6c1b820395452cc5472b8f11cd98320f40941795b8069aef4e0e0/Automat-22.10.0-py2.py3-none-any.whl (26 kB)
Collecting idna
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/fc/34/3030de6f1370931b9dbb4dad48f6ab1015ab1d32447850b9fc94e60097be/idna-3.4-py3-none-any.whl (61 kB)
Collecting requests-file>=1.4
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/77/86/cdb5e8eaed90796aa83a6d9f75cfbd37af553c47a291cd47bc410ef9bdb2/requests_file-1.5.1-py2.py3-none-any.whl (3.7 kB)
Collecting filelock>=3.0.8
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/5e/5d/97afbafd9d584ff1b45fcb354a479a3609bd97f912f8f1f6c563cb1fae21/filelock-3.12.4-py3-none-any.whl (11 kB)
Collecting requests>=2.1.0
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/70/8e/0e2d847013cb52cd35b38c009bb167a1a26b2ce6cd6965bf26b47bc0bf44/requests-2.31.0-py3-none-any.whl (62 kB)
Collecting six
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting pycparser
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/62/d5/5f610ebe421e85889f2e55e33b7f9a6795bd982198517d912eb1c76e1a53/pycparser-2.21-py2.py3-none-any.whl (118 kB)
Collecting urllib3<3,>=1.21.1
, packaging, lxml, jmespath, itemadapter, idna, filelock, cssselect, charset-normalizer, certifi, attrs, requests, pyasn1-modules, parsel, hyperlink, cffi, Automat, Twisted, requests-file, itemloaders, cryptography, tldextract, service-identity, pyOpenSSL, scrapy
Successfully installed Automat-22.10.0 PyDispatcher-2.0.7 Twisted-22.10.0 attrs-23.1.0 certifi-2023.7.22 cffi-1.15.1 charset-normalizer-3.2.0 constantly-15.1.0 cryptography-41.0.4 cssselect-1.2.0 filelock-3.12.4 hyperlink-21.0.0 idna-3.4 incremental-22.10.0 itemadapter-0.8.0 itemloaders-1.1.0 jmespath-1.0.1 lxml-4.9.3 packaging-23.1 parsel-1.8.1 protego-0.3.0 pyOpenSSL-23.2.0 pyasn1-0.5.0 pyasn1-modules-0.3.0 pycparser-2.21 queuelib-1.6.2 requests-2.31.0 requests-file-1.5.1 scrapy-2.11.0 service-identity-23.1.0 six-1.16.0 tldextract-3.6.0 twisted-iocpsupport-1.0.4 typing-extensions-4.8.0 urllib3-2.0.5 w3lib-2.1.2 zope.interface-6.0

[notice] A new release of pip available: 22.3.1 -> 23.2.1
[notice] To update, run: python.exe -m pip install --upgrade pip

但是如果我直接使用D:\Anaconda3\envs\python38_at\python.exe的虚拟环境,即使用conda命令:

activate python38_at

在python38_at中直接下载scrapy包就没问题


后来我又创建了一个 python3.8 的 anaconda 环境,用来做 Base Interpreter ,结果还是出同样的问题了。

但是当我创建 python3.8.8 的 anaconda 环境,用来做 Base Interpreter ,结果成功下载了。当我使用 3.7 和 3.8.8 版本时都没有问题,但是anaconda的 3.8 版本的 python 就有问题了。

这是成功的例子:

原因尚不明确,希望有大佬指点。现在的办法就是不要用 3.8 版本的 Base Interpreter。

posted @ 2023-09-21 23:47  dunhedunhe  阅读(328)  评论(0编辑  收藏  举报