Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 即使在安装包之后也无法导入_Python_Ubuntu_Numpy_Scipy_Scikit Learn - Fatal编程技术网

Python 即使在安装包之后也无法导入

Python 即使在安装包之后也无法导入,python,ubuntu,numpy,scipy,scikit-learn,Python,Ubuntu,Numpy,Scipy,Scikit Learn,我已经安装了numpy、scipy、scikit learn和其他必需的软件包。不过,当我尝试在python中导入它们时,它显示没有找到任何模块 pip install -U numpy scipy scikit-learn Requirement already up-to-date: numpy in /usr/lib/python2.7/dist-packages Collecting scipy Downloading scipy-0.17.1-cp27-cp27mu-manylin

我已经安装了numpy、scipy、scikit learn和其他必需的软件包。不过,当我尝试在python中导入它们时,它显示没有找到任何模块

pip install -U numpy scipy scikit-learn
Requirement already up-to-date: numpy in /usr/lib/python2.7/dist-packages
Collecting scipy
  Downloading scipy-0.17.1-cp27-cp27mu-manylinux1_x86_64.whl (39.5MB)
    100% |████████████████████████████████| 39.5MB 32kB/s 
Requirement already up-to-date: scikit-learn in /home/tecsadmin/.local/lib/python2.7/site-packages
Installing collected packages: scipy
  Found existing installation: scipy 0.17.0
    DEPRECATION: Uninstalling a distutils installed project (scipy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling scipy-0.17.0:
Exception:
Traceback (most recent call last):
  File "/home/tecsadmin/.local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/home/tecsadmin/.local/lib/python2.7/site-packages/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/home/tecsadmin/.local/lib/python2.7/site-packages/pip/req/req_set.py", line 736, in install
    requirement.uninstall(auto_confirm=True)
  File "/home/tecsadmin/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 742, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/home/tecsadmin/.local/lib/python2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/home/tecsadmin/.local/lib/python2.7/site-packages/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
  File "/usr/lib/python2.7/shutil.py", line 303, in move
    os.unlink(src)
OSError: [Errno 13] Permission denied: '/usr/lib/python2.7/dist-packages/scipy-0.17.0.egg-info'
tecsadmin@BLITZ:~/.local/lib/python2.7/site-packages/sklearn/__check_build$ python
Python 2.7.5 (default, Jun 17 2016, 04:41:21) 
[GCC 5.3.1 20160413] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>> 
pip安装-U numpy scipy scikit学习
需求已经更新:numpy in/usr/lib/python2.7/dist-packages
收集垃圾
下载scipy-0.17.1-cp27-cp27mu-manylinux1_x86_64.whl(39.5MB)
100% |████████████████████████████████| 39.5MB 32kB/s
要求已经更新:scikit-learn-in/home/tecsadmin/.local/lib/python2.7/site-packages
安装收集的软件包:scipy
找到现有安装:scipy 0.17.0
不推荐:卸载distutils安装的项目(scipy)已被不推荐,并将在将来的版本中删除。这是因为卸载distutils项目只会部分卸载该项目。
卸载scipy-0.17.0:
例外情况:
回溯(最近一次呼叫最后一次):
文件“/home/tecsadmin/.local/lib/python2.7/site packages/pip/basecommand.py”,主目录第215行
status=self.run(选项、参数)
文件“/home/tecsadmin/.local/lib/python2.7/site-packages/pip/commands/install.py”,第317行,正在运行
prefix=options.prefix\u路径,
文件“/home/tecsadmin/.local/lib/python2.7/site packages/pip/req/req_set.py”,第736行,安装中
要求.卸载(自动确认=True)
文件“/home/tecsadmin/.local/lib/python2.7/site packages/pip/req/req_install.py”,第742行,在卸载中
路径到移除。移除(自动确认)
文件“/home/tecsadmin/.local/lib/python2.7/site packages/pip/req/req_uninstall.py”,删除中的第115行
重命名(路径,新路径)
文件“/home/tecsadmin/.local/lib/python2.7/site packages/pip/utils/_init__.py”,第267行,在重命名中
shutil.移动(旧、新)
文件“/usr/lib/python2.7/shutil.py”,第303行,移动中
操作系统取消链接(src)
OSError:[Errno 13]权限被拒绝:'/usr/lib/python2.7/dist-packages/scipy-0.17.0.egg-info'
tecsadmin@BLITZ:~/.local/lib/python2.7/site packages/sklearn/\uu check\u build$python
Python 2.7.5(默认值,2016年6月17日,04:41:21)
[GCC 5.3.1 20160413]关于linux2
有关详细信息,请键入“帮助”、“版权”、“信用证”或“许可证”。
>>>进口numpy
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
ImportError:没有名为numpy的模块
>>> 
更新

admin@BLITZ:~$ sudo pip install -U numpy scipy scikit-learn
[sudo] password for tecsadmin: 
The directory '/home/tecsadmin/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/tecsadmin/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already up-to-date: numpy in /usr/lib/python2.7/dist-packages
Collecting scipy
  Downloading scipy-0.17.1-cp27-cp27mu-manylinux1_x86_64.whl (39.5MB)
    100% |████████████████████████████████| 39.5MB 32kB/s 
Requirement already up-to-date: scikit-learn in ./.local/lib/python2.7/site-packages
Installing collected packages: scipy
  Found existing installation: scipy 0.17.0
    DEPRECATION: Uninstalling a distutils installed project (scipy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling scipy-0.17.0:
      Successfully uninstalled scipy-0.17.0
Successfully installed scipy-0.17.1
tecsadmin@BLITZ:~$ python
Python 2.7.5 (default, Jun 17 2016, 04:41:21) 
[GCC 5.3.1 20160413] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>> import scipy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named scipy
admin@BLITZ:~$sudo pip安装-U numpy scipy scikit学习
tecsadmin的[sudo]密码:
当前用户不拥有目录“/home/tecsadmin/.cache/pip/http”或其父目录,并且已禁用缓存。请检查该目录的权限和所有者。如果使用sudo执行pip,您可能需要sudo的-H标志。
当前用户不拥有目录“/home/tecsadmin/.cache/pip”或其父目录,并且已禁用缓存控制盘。检查该目录的权限和所有者。如果使用sudo执行pip,您可能需要sudo的-H标志。
需求已经更新:numpy in/usr/lib/python2.7/dist-packages
收集垃圾
下载scipy-0.17.1-cp27-cp27mu-manylinux1_x86_64.whl(39.5MB)
100% |████████████████████████████████| 39.5MB 32kB/s
要求已更新:scikit学习版。/.local/lib/python2.7/site-packages
安装收集的软件包:scipy
找到现有安装:scipy 0.17.0
不推荐:卸载distutils安装的项目(scipy)已被不推荐,并将在将来的版本中删除。这是因为卸载distutils项目只会部分卸载该项目。
卸载scipy-0.17.0:
已成功卸载scipy-0.17.0
已成功安装scipy-0.17.1
tecsadmin@BLITZ:~$python
Python 2.7.5(默认值,2016年6月17日,04:41:21)
[GCC 5.3.1 20160413]关于linux2
有关详细信息,请键入“帮助”、“版权”、“信用证”或“许可证”。
>>>进口numpy
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
ImportError:没有名为numpy的模块
>>>进口西皮
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
ImportError:没有名为scipy的模块
更新2

tecsadmin@BLITZ:~$ pip freeze | grep numpy 
numpy==1.11.0
tecsadmin@BLITZ:~$ pip freeze | grep scipy
scipy==0.17.1
tecsadmin@BLITZ:~$ pip freeze | grep scikit-learn
scikit-learn==0.17.1
tecsadmin@BLITZ:~$ python
Python 2.7.5 (default, Jun 17 2016, 04:41:21) 
[GCC 5.3.1 20160413] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named scipy
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named numpy
tecsadmin@BLITZ:~$pip freeze | grep numpy
numpy==1.11.0
tecsadmin@BLITZ:~$pip freeze | grep scipy
scipy==0.17.1
tecsadmin@BLITZ:~$pip freeze | grep scikit学习
scikit学习==0.17.1
tecsadmin@BLITZ:~$python
Python 2.7.5(默认值,2016年6月17日,04:41:21)
[GCC 5.3.1 20160413]关于linux2
有关详细信息,请键入“帮助”、“版权”、“信用证”或“许可证”。
>>>进口西皮
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
ImportError:没有名为scipy的模块
>>>进口numpy
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
ImportError:没有名为numpy的模块

不确定是否相关,但您的
权限被拒绝
错误,请尝试
sudo pip安装-U numpy scipy scikit学习

要再次检查安装,请运行
pip freeze

$ pip freeze | grep numpy 
$ numpy==1.9.2
这样,您就可以真正检查它是否已成功安装


另外,我建议您使用python虚拟环境,这样您就不必使用sudo权限了

您还没有安装libs,您得到了错误13权限被拒绝。使用以下命令重新安装它们:

sudo pip install numpy scipy scikit-learn

您没有安装这些库,但出现了一个错误。@user123使用sudo pip install-U numpy scipy scikit重新安装它们-learn@wind85请检查一下更新,你能不能暂停一下?@shivsn我没听清楚。它说已经满足了要求。To:lapinkoira什么是taht?我使用Sudo安装了它,仍然显示相同的内容error@user123您的计算机上有多个站点包。您可以设置一个虚拟环境(强烈建议)并在那里安装所有需要的软件包,或者使用pip install重新安装当前的软件包--强制重新安装软件包名称。运行pip freeze,它会显示numpy和scipy已安装,让我们检查一下itOk是否可以运行