草庐IT

installation-path

全部标签

python - PYTHONPATH 如何填充 sys.path 是否可靠并记录在案?

在我的机器上,PYTHONPATH中的值似乎被插入到sys.path中:从索引1开始保留顺序去重例如,使用PYTHONPATH=/spam:/eggs:/spam然后检查python-msite,我得到如下结果:sys.path=[something,'/spam','/eggs',more,stuff,after]这在Python2和Python3上似乎是相同的行为。问题是,这种对PYTHONPATH的处理有多少是有记录的/可靠的,如果有的话在其他平台上可能会有所不同?这是嵌入到解释器中,还是由site.py处理和/或有被系统管理员“调整”的危险?我在文档中看不到它的解释here,它

python - 可以将 Python 配置为缓存 sys.path 目录查找吗?

我们一直在对通过远程连接运行的Python进行大量基准测试。该程序在异地运行,但在现场访问磁盘。我们在RHEL6下运行。我们用strace看了一个简单的程序。它似乎花费了大量时间来执行统计和打开文件以查看它们是否存在。通过昂贵的远程连接。有没有办法配置Python一次读取目录内容并缓存它的列表,这样它就不必再次检查它?示例程序test_import.py:importrandomimportitertools我运行了以下命令:$strace-Tfpythontest_import.py>&strace.out$grep'/usr/lib64/python2.6/'strace.out|

python 3 : AttributeError: 'module' object has no attribute '__path__' using urllib in terminal

我的代码在PyCharm中运行完美,但我在尝试在终端中打开它时收到错误消息。我的代码有什么问题,或者我哪里出错了?importurllib.requestwithurllib.request.urlopen('http://python.org/')asresponse:html=response.read()print(html)终端输出:λpythonDesktop\url1.pyTraceback(mostrecentcalllast):File"",line2218,in_find_and_load_unlockedAttributeError:'module'objectha

python - 为什么 os.path.join 会丢弃参数?

我正在学习Python,我发现我的一个脚本有些奇怪。做了一些测试,我发现问题源于这种行为:>>>importos>>>os.path.join('a','b')'a/b'>>>os.path.join('a','/b')'/b'检查documentation,这实际上是函数的设计:os.path.join(path1[,path2[,...]])Joinoneormorepathcomponentsintelligently.Ifanycomponentisanabsolutepath,allpreviouscomponents(onWindows,includingtheprevio

python - pip install scikit-image 出错

我使用的是Windows8.164位和Python2.7。尝试从shell安装scikit-imagepipinstallscikit-image我遇到了这个错误:命令“pythonsetup.pyegg_info”在c:\users\france~1\appdata\local\temp\pip-buildtksnfe\scikit-image\中失败,错误代码为1下载没问题,但安装失败。这里有什么问题,如何解决?编辑升级我的pip之后python-mpipinstall-Upipsetuptools再试一次,我得到了:命令“pythonsetup.pyegg_info”在c:\us

python - 如何在 Windows 上使用 pip install 修复错误 “Expected version spec in …”?

在Windows7机器上,我使用以下命令从本地目录安装包:pipinstalladdons/pnc_tests--upgrade--extra-index-url=http://some_server/simple这会导致以下错误:C:\Users\alex\PNC\tas\ENV\Scripts\pip-script.pyrunon07/16/1407:50:47Exception:Traceback(mostrecentcalllast):File"C:\Users\alex\PNC\tas\ENV\lib\site-packages\pip\basecommand.py",lin

python - "error: cannot locate an Oracle software installation"尝试安装 cx_Oracle 时

这里的新手尝试使用python进行一些数据库分析。我不断收到错误:“错误:找不到Oracle软件安装”安装CX_oracle(通过easy_install)时。问题是我的本地机器上没有oracle,我正在尝试使用python连接到主oracle服务器。我已经设置了另一个程序来执行此操作(visualdb),并且我有一个用作驱动程序的.jar文件,但我不确定在这种情况下如何使用它。有什么建议吗? 最佳答案 不要使用easy_install或pip,它们不能很好地安装cx_Oracle,因为安装脚本不会自动设置许多环境依赖项。您需要获得

python - Subprocess.call 或 Subprocess.Popen 不能使用 PATH (Linux/Windows) 中的可执行文件

我正在编写一个需要在Linux和Windows上运行并使用路径中存在的可执行文件(带参数)的程序。(假设)目前,我在使用Subprocess.Call和Subprocess.Popen在Windows中运行可执行文件时遇到问题。对于像这样的代码,在windows8中defmakeBlastDB(inFile,inputType,dbType,title,outDir):strProg='makeblastdb'strInput='-in'+inFilestrInputType='-input_type'+inputTypestrDBType='-dbtype'+dbTypestrTit

python - path.exists() 返回 False

我正在构建一个基本的文件服务器,但我的程序找不到文件。defsendfile(sock,myfile):print'Servingfile:',myfileprint'Fileexists?:',os.path.exists(myfile)path=os.path.normpath(os.path.join(os.getcwd(),myfile))print'Servingfile:',pathprint'Fileexists?:',os.path.exists(path)即使“myfile”和“path”是正确的[文件与服务器程序位于同一目录],它们总是返回False。IDLE工作正

python - 从代理服务器后面使用 ez_setup.py 安装 Python 的 easy_install

在使用代理服务器的公司网络上,有没有办法使用ez_setup.py安装Python的easy_install?目前,我收到连接超时:Downloadinghttp://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.eggTraceback(mostrecentcalllast):File"C:\jsears\python\ez_setup.py",line278,inmain(sys.argv[1:])File"C:\jsears\python\ez_setup.py",line210,inmaine