【发布时间】:2019-11-06 22:22:01
【问题描述】:
所以我已经使用 linux mint mate 一段时间了,一切正常。 因此,当我得到一个新笔记本时,我在 windows 10 旁边安装了新版本的 linux mint (19.2 - Tina)。我认为一切都很顺利。
现在,我正在尝试让它准备好使用,但它无法正常工作。
据说它带有两个版本的python:
- Python 2.7.15+
- Python 3.6.8
但是当我尝试运行一个简单的 hello world 时,为我导入了 Essentials 包,就像这样
import numpy as np
import math #as ma
import matplotlib.pyplot as plt; plt.switch_backend('agg')
import sys
import pandas as pd
import seaborn as sns; sns.set()
import powerlaw as pl
from itertools import zip_longest
import csv
import os
print('hello world')
它甚至不识别 numpy 包,我得到了以下信息:
Traceback (most recent call last):
File "testes.py", line 1, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
所以我去了这个网站并尝试按照教程进行操作
https://packaging.python.org/tutorials/installing-packages/#id18
但是当我尝试安装 numpy 时,结果如下:
(tutorial_env) jheniffer@jheniffer-5480:~/Dropbox/teste_cros_bi$ pip install python3-numpy
Collecting python3-numpy
Exception:
Traceback (most recent call last):
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/commands/install.py", line 353, in run
wb.build(autobuilding=True)
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/req/req_set.py", line 554, in _prepare_file
require_hashes
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/req/req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/index.py", line 568, in _get_pages
page = self._get_page(location)
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/lib/python3.6/site-packages/pip/index.py", line 795, in get_page
resp.raise_for_status()
File "/home/jheniffer/Dropbox/teste_cros_bi/tutorial_env/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://pypi.org/simple/python3-numpy/
我不知道我应该怎么做才能让它运行, 我应该如何继续安装所有东西,因为我认为已经安装了基本软件包,例如 numpy,并且每隔一次我尝试通过 pip 安装一些东西(在我以前的笔记本电脑上)它只使用
pip3 install python3-numpy
我试过不带pip的选项,安装成功
(tutorial_env) jheniffer@jheniffer-5480:~/Dropbox/teste_cros_bi$ sudo apt install python3-numpy
[sudo] password for jheniffer:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
gfortran python-numpy-doc python3-dev python3-nose python3-numpy-dbg
The following NEW packages will be installed:
python3-numpy
0 upgraded, 1 newly installed, 0 to remove and 287 not upgraded.
Need to get 1.943 kB of archives.
After this operation, 10,9 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 python3-numpy amd64 1:1.13.3-2ubuntu1 [1.943 kB]
Fetched 1.943 kB in 4s (528 kB/s)
Selecting previously unselected package python3-numpy.
(Reading database ... 308507 files and directories currently installed.)
Preparing to unpack .../python3-numpy_1%3a1.13.3-2ubuntu1_amd64.deb ...
Unpacking python3-numpy (1:1.13.3-2ubuntu1) ...
Setting up python3-numpy (1:1.13.3-2ubuntu1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
但是当我尝试运行 hello word 代码时,我再次收到此消息
(tutorial_env) jheniffer@jheniffer-5480:~/Dropbox/teste_cros_bi$ python3 testes.py
Traceback (most recent call last):
File "testes.py", line 1, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
【问题讨论】:
-
您是否将 Debian / Mint apt-可安装系统包
python3-numpy与其对应的 Python / PyPI pip-可安装项目numpy混淆了? -
也许,有什么区别?我尝试在没有 pip 的情况下安装它,如下所示:sudo apt install python3-numpy,它已安装,但我也不工作
标签: python python-3.x pip linux-mint