在本文中,我们将带你了解如何找到我的Pythonsite-packages目录的位置?在这篇文章中,我们将为您详细介绍如何找到我的Pythonsite-packages目录的位置?的方方面面,并解答怎
在本文中,我们将带你了解如何找到我的Python site-packages目录的位置?在这篇文章中,我们将为您详细介绍如何找到我的Python site-packages目录的位置?的方方面面,并解答怎么找到python的路径常见的疑惑,同时我们还将给您一些技巧,以帮助您实现更有效的(pyasn1 0.1.6 (/usr/lib/python2.7/site-packages),、cmake find_package找到正确的Python3但找不到正确的PythonLib-如何指定路径?、dist-packages和site-packages有什么区别?、django 的时区冲突错误 /usr/lib/python2.7/site-packages/...。
本文目录一览:- 如何找到我的Python site-packages目录的位置?(怎么找到python的路径)
- (pyasn1 0.1.6 (/usr/lib/python2.7/site-packages),
- cmake find_package找到正确的Python3但找不到正确的PythonLib-如何指定路径?
- dist-packages和site-packages有什么区别?
- django 的时区冲突错误 /usr/lib/python2.7/site-packages/...
如何找到我的Python site-packages目录的位置?(怎么找到python的路径)
如何解决如何找到我的Python site-packages目录的位置??
网站包目录有两种类型,全局目录和每个用户目录。
运行时会列出全局站点软件包(“ dist-packages ”
)目录sys.path:
python -m site
要在Python代码中getsitepackages
从站点模块运行更简洁的列表,请执行以下操作:
python -c ''import site; print(site.getsitepackages())''
注意:使用virtualenvs
时,getsitepackages
不可用,但是sys.path
从上面将正确列出virtualenv
的site-packages
目录。在Python 3中,你可以改为使用sysconfig
模块:
python3 -c ''import sysconfig; print(sysconfig.get_paths()["purelib"])''
在每个用户站点包目录(PEP 370)是其中的Python安装本地套餐:
python -m site --user-site
如果这指向一个不存在的目录,请检查Python的退出状态并查看python -m site --help
说明。
提示:运行pip list --user
或pip freeze --user
为你提供每个用户站点软件包的所有已安装列表。
实用技巧
<package>.__path__
可让你识别特定包裹的位置:(详细信息)
$ python -c "import setuptools as _; print(_.__path__)"
[''/usr/lib/python2.7/dist-packages/setuptools'']
<module>.__file__
可让你识别特定模块的位置:(差异)
$ python3 -c "import os as _; print(_.__file__)"
/usr/lib/python3.6/os.py
运行pip show <package>
以显示Debian风格的软件包信息:
$ pip show pytest
Name: pytest
Version: 3.8.2
Summary: pytest: simple powerful testing with Python
Home-page: https://docs.pytest.org/en/latest/
Author: Holger Krekel, Bruno Oliveira, Ronny Pfannschmidt, Floris Bruynooghe, Brianna Laugher, Florian Bruhin and others
Author-email: None
License: MIT license
Location: /home/peter/.local/lib/python3.4/site-packages
Requires: more-itertools, atomicwrites, setuptools, attrs, pathlib2, six, py, pluggy
解决方法
如何找到我的site-packages目录的位置?
(pyasn1 0.1.6 (/usr/lib/python2.7/site-packages),
ubuntu14.04 下安装爬虫工具 scrapy
scrapy 是目前准备要学习的爬虫框架,其在 ubuntu14.04 下的安装过程如下:
ubuntu14.04 下默认安装了 2.7 的 python 以及 setuptools,若未安装,可通过下面指令安装:
sudo apt-get install pythonsudo apt-get install python-setuptools
然后安装 Twisted:
sudo apt-get install python-twisted
然后是 Scrapy:
sudo apt-get install python-scrapy
安装完成后,如果直接键入 scrapy 启动的话会报类似如下错误:
File "/usr/local/bin/scrapy", line 5, in <module>
from pkg_resources import load_entry_point
......
pkg_resources.ContextualVersionConflict: (pyasn1 0.1.7 (/usr/lib/python2.7/dist-packages), Requirement.parse(''pyasn1>=0.1.8''), set([''pyasn1-modules'']))
按提示是个版本依赖的错误。
此时先安装 pip:
sudo apt-get install python-pip
升级 pip:
sudo pip install --upgrade pip
然后对提示的 pyasn1 升级:
sudo pip install --upgrade pyasn1
再启动 scrapy 就可以成功了:
Scrapy 1.0.3 - no active project
Usage:
scrapy <command> [options] [args]
Available commands:
bench Run quick benchmark test
commands
fetch Fetch a URL using the Scrapy downloader
runspider Run a self-contained spider (without creating a project)
settings Get settings values
shell Interactive scraping console
startproject Create new project
version Print Scrapy version
view Open URL in browser, as seen by Scrapy
[ more ] More commands available when run from project directory
Use "scrapy <command> -h" to see more info about a command
cmake find_package找到正确的Python3但找不到正确的PythonLib-如何指定路径?
如何解决cmake find_package找到正确的Python3但找不到正确的PythonLib-如何指定路径??
我如何指定cmake仅应在特定的conda环境中搜索python?
我使用cmake -B build
运行以下CMakeLists.txt:
project(FindPythonProblem)
cmake_minimum_required(VERSION 3.18)
find_package (python3 3.6 EXACT required)
if (python3_FOUND)
message (STATUS "python3 found")
endif ()
find_package (python3 3.6 EXACT required COMPONENTS Interpreter)
if (python3_Interpreter_FOUND)
message (STATUS "python3 Interpreter found")
endif ()
find_package (PythonLibs 3.6 required)
if (PYTHONLIBS_FOUND)
message (STATUS "PythonLibs found")
endif ()
相关的输出是
-- Found python3: C:/Miniconda3/envs/forboost/python.exe (found suitable exact version "3.6.12") found components: Interpreter
-- python3 found
-- python3 Interpreter found
-- Found PythonLibs: C:/Miniconda3/libs/python37.lib (found suitable version "3.7.4",minimum required is "3.6")
-- PythonLibs found
虽然在conda环境forboost
中找到了Python 3.6,但相应的PythonLib却找不到conda环境forboost
的3.6版本。我如何指定cmake仅应在conda环境中搜索以增强效果?
find_package (PythonLibs 3.6 EXACT required)
行将导致错误,因为找不到合适的版本。
有关更多信息:C:/Miniconda3
中有一个python 3.7,C:/Miniconda3/envs/forboost
中有一个我想使用的python 3.6。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
dist-packages和site-packages有什么区别?
我对python软件包的安装过程有点不满意。具体来说,安装在dist-packages目录和site-packages目录中的软件包有什么区别?
答案1
小编典典dist-
packages是特定于Debian的约定,也存在于其衍生版本中,例如Ubuntu。当模块从Debian软件包管理器进入以下位置时,它们将安装到dist-
packages中:
/usr/lib/python2.7/dist-packages
由于easy_install
和pip
是从软件包管理器安装的,因此它们也使用dist-packages,但是它们将软件包放在此处:
/usr/local/lib/python2.7/dist-packages
从Debian Python Wiki:
dist-packages而不是site-
packages。从Debian软件包安装的第三方Python软件将放入dist软件包,而不是站点软件包。这是为了减少系统Python与您可能手动安装的任何源Python构建之间的冲突。
这意味着,如果您从源代码手动安装Python,它将使用site-
packages目录。这使您可以将两个安装分开,特别是因为Debian和Ubuntu在许多系统实用程序中都依赖Python的系统版本。
django 的时区冲突错误 /usr/lib/python2.7/site-packages/...
这个错误大概不会影响你的一些主要功能,但是在终端会显示 warning 的。
错误的原因比较明显,就是 DateTimeField received a naive datetime while time zone support is active. 所谓的数据库中存储 DateTimeField 类型项的时候,收到一个本地的时间,但是 django 的时区是动态的(默认一般是 US 的时区)。
修这个 bug 很简单,就是在 settings.py 中,找到,将 USE_TZ 的值改为 False 就可以了:
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = False
关于如何找到我的Python site-packages目录的位置?和怎么找到python的路径的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于(pyasn1 0.1.6 (/usr/lib/python2.7/site-packages),、cmake find_package找到正确的Python3但找不到正确的PythonLib-如何指定路径?、dist-packages和site-packages有什么区别?、django 的时区冲突错误 /usr/lib/python2.7/site-packages/...等相关知识的信息别忘了在本站进行查找喔。
本文标签: