当前位置: 首页 > 面试题库 >

点安装无法安装到正确的目录?

唐博文
2023-03-14
问题内容

我似乎无法正确使用sudo pip install来将其安装到以下目录中:

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/

这样我就可以使用python导入模块

我跑了

sudo pip install scikit-learn --upgrade

结果

Requirement already up-to-date: scikit-learn in /usr/local/lib/python2.7/site-packages
Cleaning up...

但是,它不在正确的目录中

如何获得sudo pip install安装到正确的目录?

另外,我尝试了

sudo pip安装Scrappy

我收到以下消息

new-host-2:site-packages Chris$ sudo pip install Scrapy
Password:
Requirement already satisfied (use --upgrade to upgrade): Scrapy in /usr/local/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): Twisted>=10.0.0 in /usr/local/lib/python2.7/site-packages (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): w3lib>=1.8.0 in /usr/local/lib/python2.7/site-packages (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): queuelib in /usr/local/lib/python2.7/site-packages (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): lxml in /usr/local/lib/python2.7/site-packages (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): pyOpenSSL in /usr/local/lib/python2.7/site-packages (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): cssselect>=0.9 in /usr/local/lib/python2.7/site-packages (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): six>=1.5.2 in /usr/local/lib/python2.7/site-packages (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): zope.interface>=3.6.0 in /usr/local/lib/python2.7/site-packages (from Twisted>=10.0.0->Scrapy)
Requirement already satisfied (use --upgrade to upgrade): cryptography>=0.2.1 in /usr/local/lib/python2.7/site-packages (from pyOpenSSL->Scrapy)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/local/lib/python2.7/site-packages (from zope.interface>=3.6.0->Twisted>=10.0.0->Scrapy)
Requirement already satisfied (use --upgrade to upgrade): cffi>=0.8 in /usr/local/lib/python2.7/site-packages (from cryptography>=0.2.1->pyOpenSSL->Scrapy)
Requirement already satisfied (use --upgrade to upgrade): pycparser in /usr/local/lib/python2.7/site-packages (from cffi>=0.8->cryptography>=0.2.1->pyOpenSSL->Scrapy)

这两个实例均表明已安装但未正确安装。例如,当我在python中运行以下导入时:

import scrapy
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-6-51c73a18167b> in <module>()
----> 1 import scrapy

ImportError: No module named scrapy

我尝试了以下方法

sudo ln -s /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/

问题答案:

从注释到原始问题,似乎您安装了多个版本的python,而pip只是使用了错误的版本。

首先,要知道您使用的是哪个版本的python,只需输入即可which python。您应该看到:

which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python

如果您要使用正确的python版本,或者:

which python
/usr/bin/python

如果您要使用“错误”版本。为了使pip转到正确的版本,您首先必须更改路径:

 export PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin/python:${PATH}

现在输入“哪个python”将使您获得正确的结果。接下来,安装pip(如果尚未安装此python,则安装pip)。最后,使用它。您现在应该很好。



 类似资料:
  • 我似乎不能正确使用sudo pip安装,以便它安装到以下目录: 这样我就可以使用python导入模块 我跑过了 结果 但是,它不在正确的目录中 如何让sudo pip安装到正确的目录? 另外,我也试过了 sudo-pip安装刮擦 我得到以下信息 这两个实例都表明它已经安装,但并不正确。例如,当我在python中运行以下导入: 我尝试了以下方法:

  • 已从deb软件包安装docker1.6,但在运行时出现问题: sudo docker版本客户端版本: 1.6.2客户端API版本: 1.18 Go版本(客户端): go1.4.2 Git提交(客户端): 7c8fca2 OS/Arch(客户端): linux/amd64 FATA[0000]获取超文本传输协议:///var/run/docker.sock/v1.18/version:拨号unix

  • 无法完成安装,因为找不到一个或多个必需的项目。 正在安装的软件:M2E-Maven Integration for Eclipse(包括孵化组件)1.6.1.20150625-2338(org.Eclipse.m2e.feature.feature.group 1.6.1.20150625-2338)缺少要求:Maven Integration for Eclipse 1.6.0.20150526

  • gradle_opts=f:\localrepository\gradle-1.3\bin PATH=F:\localrepository\gradle-1.3\bin;F:\jdk1.7.0_21\bin java_home=f:\jdk1.7.0_21 有人能告诉我我在这里缺少什么吗?

  • 我有一个很多人都有的错误,我认为我在这里找到了一个解决方案。本质上,它是说我的节点版本与node-sass版本不兼容。很多人都有同样的问题,所以我相信链接会有所帮助。然而,当我运行npm安装node-sass@4.14.1时,我得到了一个不同的错误。我知道这是一些简单的修复,但我找不到它!有人明白这是怎么回事吗?

  • 问题内容: 所以几周前,我的Eclipse IDE不再允许我远程调试我的应用程序,说它由于未显示行号而无法安装断点…问题是我的Eclipse设置为显示行号(我在日常开发中经常使用) 我进行了一些研究,发现它有时与使用ant来构建项目以及javac中的调​​试设置有关。我确保在我的build.xml目标中设置了调试功能,但仍然无法让我调试相同的错误。 现在,为了加重伤害,我单击了“不再显示此消息”框