小编sro*_*uex的帖子

clang:error :::在Mac OSX El Capitan构建XGBoost上的错误支持选项'-fopenmp'

我正在尝试按照以下说明为Python 构建XGBoost包:

以下是使用支持OpenMP的编译器安装XGBoost的完整解决方案.通过openmp支持获得gcc-5.xx brew install gcc --without-multilib.(brew是OS X上apt-get的事实标准.因此不建议单独安装HPC,但它应该可以工作.):

git clone --recursive https://github.com/dmlc/xgboost
cd xgboost; cp make/config.mk ./config.mk; make -j4
Run Code Online (Sandbox Code Playgroud)

此错误恰好在make -j4命令中发生.

在beforenad之前搜索,我尝试了这两个解决方案(12),但没有用,除了因为害怕搞乱一切而安装另一个gcc的部分.

以下是make配置文件.它没有任何可疑之处.

#-----------------------------------------------------
#  xgboost: the configuration compile script
#
#  If you want to change the configuration, please use the following
#  steps. Assume you are on the root directory of xgboost.
#  First copy the this file so that any local changes will be …
Run Code Online (Sandbox Code Playgroud)

python macos gcc xgboost

23
推荐指数
2
解决办法
2万
查看次数

如何在pandas date_range方法中包含结束日期?

pd.date_range('2016-01', '2016-05', freq='M', ).strftime('%Y-%m')上个月开始2016-04,但我期待它2016-05.在我看来,这个函数的行为与range方法类似,其中end参数不包含在返回数组中.

有没有办法在返回的数组中包含结束月份,而不处理结束月份的字符串?

python string datetime range pandas

11
推荐指数
3
解决办法
4352
查看次数

如何在Mac OS Sierra上使用Python3.5安装virtualenvwrapper?

好吧,环顾四周,有很多关于如何在Mac上正确安装virtualenvwrapper的问题.我真的尝试了所有这些,但无济于事.我注意到以前的问题没有像我的电脑那样的配置,所以这里是:

  1. Mac OS Sierra 10.12
  2. 从Mac OS的python.org安装程序安装Python3.5.2
  3. 此安装将Python3.5.2置于此路径中: /Library/Frameworks/Python.framework/Versions/3.5/bin/python3
  4. 正如我所想,我已经运行python3 get-pip.py命令pip正确安装
  5. sudo pip3 virtualenvwrapper 确保所有设置都按预期完成
  6. 文档所述,~/.bash_profile使用以下代码进行编辑:
    export WORKON_HOME=$HOME/.virtualenvs
    export PROJECT_HOME=$HOME/projects
    source /usr/local/bin/virtualenvwrapper.sh
    

然后,每当我打开一个新的终端时,我得到了这个:


/usr/bin/python: No module named virtualenvwrapper virtualenvwrapper.sh:
There was a problem running the initialization hooks. 

If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for 
 VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is set properly.

我尝试过其他问题的修复,但无济于事:

  1. VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3在virtualenvwrapper.sh上设置
  2. VIRTUALENVWRAPPER_PYTHON="$(command \which python3)"在virtualenvwrapper.sh上设置
  3. ln -fs /Library/Frameworks/Python.framework/Versions/3.5/bin/python3 …

macos terminal virtualenvwrapper python-3.5

6
推荐指数
2
解决办法
4947
查看次数

有没有办法在不下载Python中的url内容的情况下获取响应头?

我正在使用Python编写一个管理器,它会在某些条件下下载一些文件.问题是要对响应头执行条件.

以下示例是我现在正在做的简化版本.我首先下载该文件,然后测试其包含在标题中的名称是否在先前定义的列表中.

我想知道是否有办法在不下载内容的情况下获得响应,这在我的实际案例中需要花费大量时间.

import requests

# The line below download the file, but I'd like not to do it.
req = requests.get('http://some_url.com/some_file')

# Get the name of the file to test if it's the right file.
r = re.search(r'filename="(.*)";', req.headers['Content-Disposition'])

filename = None

# If the filename is present in the headers...
if r.groups():
    filename = r.groups()[0]

# If the filename is in an authorized list...
if filename in [...]:
   # Process req.content
Run Code Online (Sandbox Code Playgroud)

python response request http-headers python-requests

1
推荐指数
1
解决办法
2046
查看次数

Beautifulsoup不在特定网站上工作

我正在尝试解析这个网站,由于我无法理解的原因,没有任何事情发生.

url = 'http://www.zap.com.br/imoveis/rio-de-janeiro+rio-de-janeiro/apartamento-padrao/venda/'
response = urllib2.urlopen(url).read()
doc = BeautifulSoup(response)
divs = doc.findAll('div')
print len(divs) # prints 0.
Run Code Online (Sandbox Code Playgroud)

该网站是巴西里约热内卢的一个真实广告.我在html源代码中找不到任何可以阻止Beautifulsoup工作的东西.这是大小吗?

我正在使用Enthought Canopy Python 2.7.6,IPython Notebook 2.0,Beautifulsoup 4.3.2.

html python beautifulsoup html-parsing python-2.7

0
推荐指数
1
解决办法
407
查看次数